home *** CD-ROM | disk | FTP | other *** search
/ CU Amiga Super CD-ROM 6 / CU Amiga Magazine's Super CD-ROM 06 (1996)(EMAP Images)(GB)(Track 1 of 4)[!][issue 1997-01].iso / cucd / prog / gnu-c / src / gcc-2.7.0-amiga / expr.c < prev    next >
C/C++ Source or Header  |  1995-06-15  |  329KB  |  10,690 lines

  1. /* Convert tree expression to rtl instructions, for GNU compiler.
  2.    Copyright (C) 1988, 1992, 1993, 1994, 1995 Free Software Foundation, Inc.
  3.  
  4. This file is part of GNU CC.
  5.  
  6. GNU CC is free software; you can redistribute it and/or modify
  7. it under the terms of the GNU General Public License as published by
  8. the Free Software Foundation; either version 2, or (at your option)
  9. any later version.
  10.  
  11. GNU CC is distributed in the hope that it will be useful,
  12. but WITHOUT ANY WARRANTY; without even the implied warranty of
  13. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  14. GNU General Public License for more details.
  15.  
  16. You should have received a copy of the GNU General Public License
  17. along with GNU CC; see the file COPYING.  If not, write to
  18. the Free Software Foundation, 59 Temple Place - Suite 330,
  19. Boston, MA 02111-1307, USA.  */
  20.  
  21.  
  22. #include "config.h"
  23. #include "machmode.h"
  24. #include "rtl.h"
  25. #include "tree.h"
  26. #include "obstack.h"
  27. #include "flags.h"
  28. #include "regs.h"
  29. #include "function.h"
  30. #include "insn-flags.h"
  31. #include "insn-codes.h"
  32. #include "expr.h"
  33. #include "insn-config.h"
  34. #include "recog.h"
  35. #include "output.h"
  36. #include "typeclass.h"
  37.  
  38. #include "bytecode.h"
  39. #include "bc-opcode.h"
  40. #include "bc-typecd.h"
  41. #include "bc-optab.h"
  42. #include "bc-emit.h"
  43.  
  44.  
  45. #define CEIL(x,y) (((x) + (y) - 1) / (y))
  46.  
  47. /* Decide whether a function's arguments should be processed
  48.    from first to last or from last to first.
  49.  
  50.    They should if the stack and args grow in opposite directions, but
  51.    only if we have push insns.  */
  52.  
  53. #ifdef PUSH_ROUNDING
  54.  
  55. #if defined (STACK_GROWS_DOWNWARD) != defined (ARGS_GROW_DOWNWARD)
  56. #define PUSH_ARGS_REVERSED    /* If it's last to first */
  57. #endif
  58.  
  59. #endif
  60.  
  61. #ifndef STACK_PUSH_CODE
  62. #ifdef STACK_GROWS_DOWNWARD
  63. #define STACK_PUSH_CODE PRE_DEC
  64. #else
  65. #define STACK_PUSH_CODE PRE_INC
  66. #endif
  67. #endif
  68.  
  69. /* Like STACK_BOUNDARY but in units of bytes, not bits.  */
  70. #define STACK_BYTES (STACK_BOUNDARY / BITS_PER_UNIT)
  71.  
  72. /* If this is nonzero, we do not bother generating VOLATILE
  73.    around volatile memory references, and we are willing to
  74.    output indirect addresses.  If cse is to follow, we reject
  75.    indirect addresses so a useful potential cse is generated;
  76.    if it is used only once, instruction combination will produce
  77.    the same indirect address eventually.  */
  78. int cse_not_expected;
  79.  
  80. /* Nonzero to generate code for all the subroutines within an
  81.    expression before generating the upper levels of the expression.
  82.    Nowadays this is never zero.  */
  83. int do_preexpand_calls = 1;
  84.  
  85. /* Number of units that we should eventually pop off the stack.
  86.    These are the arguments to function calls that have already returned.  */
  87. int pending_stack_adjust;
  88.  
  89. /* Nonzero means stack pops must not be deferred, and deferred stack
  90.    pops must not be output.  It is nonzero inside a function call,
  91.    inside a conditional expression, inside a statement expression,
  92.    and in other cases as well.  */
  93. int inhibit_defer_pop;
  94.  
  95. /* A list of all cleanups which belong to the arguments of
  96.    function calls being expanded by expand_call.  */
  97. tree cleanups_this_call;
  98.  
  99. /* When temporaries are created by TARGET_EXPRs, they are created at
  100.    this level of temp_slot_level, so that they can remain allocated
  101.    until no longer needed.  CLEANUP_POINT_EXPRs define the lifetime
  102.    of TARGET_EXPRs.  */
  103. int target_temp_slot_level;
  104.  
  105. /* Nonzero means __builtin_saveregs has already been done in this function.
  106.    The value is the pseudoreg containing the value __builtin_saveregs
  107.    returned.  */
  108. static rtx saveregs_value;
  109.  
  110. /* Similarly for __builtin_apply_args.  */
  111. static rtx apply_args_value;
  112.  
  113. /* This structure is used by move_by_pieces to describe the move to
  114.    be performed.  */
  115.  
  116. struct move_by_pieces
  117. {
  118.   rtx to;
  119.   rtx to_addr;
  120.   int autinc_to;
  121.   int explicit_inc_to;
  122.   int to_struct;
  123.   rtx from;
  124.   rtx from_addr;
  125.   int autinc_from;
  126.   int explicit_inc_from;
  127.   int from_struct;
  128.   int len;
  129.   int offset;
  130.   int reverse;
  131. };
  132.  
  133. /* Used to generate bytecodes: keep track of size of local variables,
  134.    as well as depth of arithmetic stack. (Notice that variables are
  135.    stored on the machine's stack, not the arithmetic stack.) */
  136.  
  137. extern int local_vars_size;
  138. extern int stack_depth;
  139. extern int max_stack_depth;
  140. extern struct obstack permanent_obstack;
  141.  
  142.  
  143. static rtx enqueue_insn        PROTO((rtx, rtx));
  144. static int queued_subexp_p    PROTO((rtx));
  145. static void init_queue        PROTO((void));
  146. static void move_by_pieces    PROTO((rtx, rtx, int, int));
  147. static int move_by_pieces_ninsns PROTO((unsigned int, int));
  148. static void move_by_pieces_1    PROTO((rtx (*) (), enum machine_mode,
  149.                        struct move_by_pieces *));
  150. static void store_constructor    PROTO((tree, rtx));
  151. static rtx store_field        PROTO((rtx, int, int, enum machine_mode, tree,
  152.                        enum machine_mode, int, int, int));
  153. static int get_inner_unaligned_p PROTO((tree));
  154. static tree save_noncopied_parts PROTO((tree, tree));
  155. static tree init_noncopied_parts PROTO((tree, tree));
  156. static int safe_from_p        PROTO((rtx, tree));
  157. static int fixed_type_p        PROTO((tree));
  158. static int get_pointer_alignment PROTO((tree, unsigned));
  159. static tree string_constant    PROTO((tree, tree *));
  160. static tree c_strlen        PROTO((tree));
  161. static rtx expand_builtin    PROTO((tree, rtx, rtx,
  162.                        enum machine_mode, int));
  163. static int apply_args_size    PROTO((void));
  164. static int apply_result_size    PROTO((void));
  165. static rtx result_vector    PROTO((int, rtx));
  166. static rtx expand_builtin_apply_args PROTO((void));
  167. static rtx expand_builtin_apply    PROTO((rtx, rtx, rtx));
  168. static void expand_builtin_return PROTO((rtx));
  169. static rtx expand_increment    PROTO((tree, int));
  170. rtx bc_expand_increment        PROTO((struct increment_operator *, tree));
  171. tree bc_runtime_type_code     PROTO((tree));
  172. rtx bc_allocate_local        PROTO((int, int));
  173. void bc_store_memory         PROTO((tree, tree));
  174. tree bc_expand_component_address PROTO((tree));
  175. tree bc_expand_address         PROTO((tree));
  176. void bc_expand_constructor     PROTO((tree));
  177. void bc_adjust_stack         PROTO((int));
  178. tree bc_canonicalize_array_ref    PROTO((tree));
  179. void bc_load_memory        PROTO((tree, tree));
  180. void bc_load_externaddr        PROTO((rtx));
  181. void bc_load_externaddr_id    PROTO((tree, int));
  182. void bc_load_localaddr        PROTO((rtx));
  183. void bc_load_parmaddr        PROTO((rtx));
  184. static void preexpand_calls    PROTO((tree));
  185. static void do_jump_by_parts_greater PROTO((tree, int, rtx, rtx));
  186. void do_jump_by_parts_greater_rtx PROTO((enum machine_mode, int, rtx, rtx, rtx, rtx));
  187. static void do_jump_by_parts_equality PROTO((tree, rtx, rtx));
  188. static void do_jump_by_parts_equality_rtx PROTO((rtx, rtx, rtx));
  189. static void do_jump_for_compare    PROTO((rtx, rtx, rtx));
  190. static rtx compare        PROTO((tree, enum rtx_code, enum rtx_code));
  191. static rtx do_store_flag    PROTO((tree, rtx, enum machine_mode, int));
  192. static tree defer_cleanups_to    PROTO((tree));
  193. extern void (*interim_eh_hook)    PROTO((tree));
  194.  
  195. /* Record for each mode whether we can move a register directly to or
  196.    from an object of that mode in memory.  If we can't, we won't try
  197.    to use that mode directly when accessing a field of that mode.  */
  198.  
  199. static char direct_load[NUM_MACHINE_MODES];
  200. static char direct_store[NUM_MACHINE_MODES];
  201.  
  202. /* MOVE_RATIO is the number of move instructions that is better than
  203.    a block move.  */
  204.  
  205. #ifndef MOVE_RATIO
  206. #if defined (HAVE_movstrqi) || defined (HAVE_movstrhi) || defined (HAVE_movstrsi) || defined (HAVE_movstrdi) || defined (HAVE_movstrti)
  207. #define MOVE_RATIO 2
  208. #else
  209. /* A value of around 6 would minimize code size; infinity would minimize
  210.    execution time.  */
  211. #define MOVE_RATIO 15
  212. #endif
  213. #endif
  214.  
  215. /* This array records the insn_code of insns to perform block moves.  */
  216. enum insn_code movstr_optab[NUM_MACHINE_MODES];
  217.  
  218. /* SLOW_UNALIGNED_ACCESS is non-zero if unaligned accesses are very slow. */
  219.  
  220. #ifndef SLOW_UNALIGNED_ACCESS
  221. #define SLOW_UNALIGNED_ACCESS STRICT_ALIGNMENT
  222. #endif
  223.  
  224. /* Register mappings for target machines without register windows.  */
  225. #ifndef INCOMING_REGNO
  226. #define INCOMING_REGNO(OUT) (OUT)
  227. #endif
  228. #ifndef OUTGOING_REGNO
  229. #define OUTGOING_REGNO(IN) (IN)
  230. #endif
  231.  
  232. /* Maps used to convert modes to const, load, and store bytecodes. */
  233. enum bytecode_opcode mode_to_const_map[MAX_MACHINE_MODE];
  234. enum bytecode_opcode mode_to_load_map[MAX_MACHINE_MODE];
  235. enum bytecode_opcode mode_to_store_map[MAX_MACHINE_MODE];
  236.  
  237. /* Initialize maps used to convert modes to const, load, and store
  238.    bytecodes. */
  239. void
  240. bc_init_mode_to_opcode_maps ()
  241. {
  242.   int mode;
  243.  
  244.   for (mode = 0; mode < (int) MAX_MACHINE_MODE; mode++)
  245.     mode_to_const_map[mode] =
  246.       mode_to_load_map[mode] =
  247.     mode_to_store_map[mode] = neverneverland;
  248.       
  249. #define DEF_MODEMAP(SYM, CODE, UCODE, CONST, LOAD, STORE) \
  250.   mode_to_const_map[(int) SYM] = CONST; \
  251.   mode_to_load_map[(int) SYM] = LOAD; \
  252.   mode_to_store_map[(int) SYM] = STORE;
  253.  
  254. #include "modemap.def"
  255. #undef DEF_MODEMAP
  256. }
  257.  
  258. /* This is run once per compilation to set up which modes can be used
  259.    directly in memory and to initialize the block move optab.  */
  260.  
  261. void
  262. init_expr_once ()
  263. {
  264.   rtx insn, pat;
  265.   enum machine_mode mode;
  266.   /* Try indexing by frame ptr and try by stack ptr.
  267.      It is known that on the Convex the stack ptr isn't a valid index.
  268.      With luck, one or the other is valid on any machine.  */
  269.   rtx mem = gen_rtx (MEM, VOIDmode, stack_pointer_rtx);
  270.   rtx mem1 = gen_rtx (MEM, VOIDmode, frame_pointer_rtx);
  271.  
  272.   start_sequence ();
  273.   insn = emit_insn (gen_rtx (SET, 0, 0));
  274.   pat = PATTERN (insn);
  275.  
  276.   for (mode = VOIDmode; (int) mode < NUM_MACHINE_MODES;
  277.        mode = (enum machine_mode) ((int) mode + 1))
  278.     {
  279.       int regno;
  280.       rtx reg;
  281.       int num_clobbers;
  282.  
  283.       direct_load[(int) mode] = direct_store[(int) mode] = 0;
  284.       PUT_MODE (mem, mode);
  285.       PUT_MODE (mem1, mode);
  286.  
  287.       /* See if there is some register that can be used in this mode and
  288.      directly loaded or stored from memory.  */
  289.  
  290.       if (mode != VOIDmode && mode != BLKmode)
  291.     for (regno = 0; regno < FIRST_PSEUDO_REGISTER
  292.          && (direct_load[(int) mode] == 0 || direct_store[(int) mode] == 0);
  293.          regno++)
  294.       {
  295.         if (! HARD_REGNO_MODE_OK (regno, mode))
  296.           continue;
  297.  
  298.         reg = gen_rtx (REG, mode, regno);
  299.  
  300.         SET_SRC (pat) = mem;
  301.         SET_DEST (pat) = reg;
  302.         if (recog (pat, insn, &num_clobbers) >= 0)
  303.           direct_load[(int) mode] = 1;
  304.  
  305.         SET_SRC (pat) = mem1;
  306.         SET_DEST (pat) = reg;
  307.         if (recog (pat, insn, &num_clobbers) >= 0)
  308.           direct_load[(int) mode] = 1;
  309.  
  310.         SET_SRC (pat) = reg;
  311.         SET_DEST (pat) = mem;
  312.         if (recog (pat, insn, &num_clobbers) >= 0)
  313.           direct_store[(int) mode] = 1;
  314.  
  315.         SET_SRC (pat) = reg;
  316.         SET_DEST (pat) = mem1;
  317.         if (recog (pat, insn, &num_clobbers) >= 0)
  318.           direct_store[(int) mode] = 1;
  319.       }
  320.     }
  321.  
  322.   end_sequence ();
  323. }
  324.       
  325. /* This is run at the start of compiling a function.  */
  326.  
  327. void
  328. init_expr ()
  329. {
  330.   init_queue ();
  331.  
  332.   pending_stack_adjust = 0;
  333.   inhibit_defer_pop = 0;
  334.   cleanups_this_call = 0;
  335.   saveregs_value = 0;
  336.   apply_args_value = 0;
  337.   forced_labels = 0;
  338. }
  339.  
  340. /* Save all variables describing the current status into the structure *P.
  341.    This is used before starting a nested function.  */
  342.  
  343. void
  344. save_expr_status (p)
  345.      struct function *p;
  346. {
  347.   /* Instead of saving the postincrement queue, empty it.  */
  348.   emit_queue ();
  349.  
  350.   p->pending_stack_adjust = pending_stack_adjust;
  351.   p->inhibit_defer_pop = inhibit_defer_pop;
  352.   p->cleanups_this_call = cleanups_this_call;
  353.   p->saveregs_value = saveregs_value;
  354.   p->apply_args_value = apply_args_value;
  355.   p->forced_labels = forced_labels;
  356.  
  357.   pending_stack_adjust = 0;
  358.   inhibit_defer_pop = 0;
  359.   cleanups_this_call = 0;
  360.   saveregs_value = 0;
  361.   apply_args_value = 0;
  362.   forced_labels = 0;
  363. }
  364.  
  365. /* Restore all variables describing the current status from the structure *P.
  366.    This is used after a nested function.  */
  367.  
  368. void
  369. restore_expr_status (p)
  370.      struct function *p;
  371. {
  372.   pending_stack_adjust = p->pending_stack_adjust;
  373.   inhibit_defer_pop = p->inhibit_defer_pop;
  374.   cleanups_this_call = p->cleanups_this_call;
  375.   saveregs_value = p->saveregs_value;
  376.   apply_args_value = p->apply_args_value;
  377.   forced_labels = p->forced_labels;
  378. }
  379.  
  380. /* Manage the queue of increment instructions to be output
  381.    for POSTINCREMENT_EXPR expressions, etc.  */
  382.  
  383. static rtx pending_chain;
  384.  
  385. /* Queue up to increment (or change) VAR later.  BODY says how:
  386.    BODY should be the same thing you would pass to emit_insn
  387.    to increment right away.  It will go to emit_insn later on.
  388.  
  389.    The value is a QUEUED expression to be used in place of VAR
  390.    where you want to guarantee the pre-incrementation value of VAR.  */
  391.  
  392. static rtx
  393. enqueue_insn (var, body)
  394.      rtx var, body;
  395. {
  396.   pending_chain = gen_rtx (QUEUED, GET_MODE (var),
  397.                var, NULL_RTX, NULL_RTX, body, pending_chain);
  398.   return pending_chain;
  399. }
  400.  
  401. /* Use protect_from_queue to convert a QUEUED expression
  402.    into something that you can put immediately into an instruction.
  403.    If the queued incrementation has not happened yet,
  404.    protect_from_queue returns the variable itself.
  405.    If the incrementation has happened, protect_from_queue returns a temp
  406.    that contains a copy of the old value of the variable.
  407.  
  408.    Any time an rtx which might possibly be a QUEUED is to be put
  409.    into an instruction, it must be passed through protect_from_queue first.
  410.    QUEUED expressions are not meaningful in instructions.
  411.  
  412.    Do not pass a value through protect_from_queue and then hold
  413.    on to it for a while before putting it in an instruction!
  414.    If the queue is flushed in between, incorrect code will result.  */
  415.  
  416. rtx
  417. protect_from_queue (x, modify)
  418.      register rtx x;
  419.      int modify;
  420. {
  421.   register RTX_CODE code = GET_CODE (x);
  422.  
  423. #if 0  /* A QUEUED can hang around after the queue is forced out.  */
  424.   /* Shortcut for most common case.  */
  425.   if (pending_chain == 0)
  426.     return x;
  427. #endif
  428.  
  429.   if (code != QUEUED)
  430.     {
  431.       /* A special hack for read access to (MEM (QUEUED ...)) to facilitate
  432.      use of autoincrement.  Make a copy of the contents of the memory
  433.      location rather than a copy of the address, but not if the value is
  434.      of mode BLKmode.  Don't modify X in place since it might be
  435.      shared.  */
  436.       if (code == MEM && GET_MODE (x) != BLKmode
  437.       && GET_CODE (XEXP (x, 0)) == QUEUED && !modify)
  438.     {
  439.       register rtx y = XEXP (x, 0);
  440.       register rtx new = gen_rtx (MEM, GET_MODE (x), QUEUED_VAR (y));
  441.  
  442.       MEM_IN_STRUCT_P (new) = MEM_IN_STRUCT_P (x);
  443.       RTX_UNCHANGING_P (new) = RTX_UNCHANGING_P (x);
  444.       MEM_VOLATILE_P (new) = MEM_VOLATILE_P (x);
  445.  
  446.       if (QUEUED_INSN (y))
  447.         {
  448.           register rtx temp = gen_reg_rtx (GET_MODE (new));
  449.           emit_insn_before (gen_move_insn (temp, new),
  450.                 QUEUED_INSN (y));
  451.           return temp;
  452.         }
  453.       return new;
  454.     }
  455.       /* Otherwise, recursively protect the subexpressions of all
  456.      the kinds of rtx's that can contain a QUEUED.  */
  457.       if (code == MEM)
  458.     {
  459.       rtx tem = protect_from_queue (XEXP (x, 0), 0);
  460.       if (tem != XEXP (x, 0))
  461.         {
  462.           x = copy_rtx (x);
  463.           XEXP (x, 0) = tem;
  464.         }
  465.     }
  466.       else if (code == PLUS || code == MULT)
  467.     {
  468.       rtx new0 = protect_from_queue (XEXP (x, 0), 0);
  469.       rtx new1 = protect_from_queue (XEXP (x, 1), 0);
  470.       if (new0 != XEXP (x, 0) || new1 != XEXP (x, 1))
  471.         {
  472.           x = copy_rtx (x);
  473.           XEXP (x, 0) = new0;
  474.           XEXP (x, 1) = new1;
  475.         }
  476.     }
  477.       return x;
  478.     }
  479.   /* If the increment has not happened, use the variable itself.  */
  480.   if (QUEUED_INSN (x) == 0)
  481.     return QUEUED_VAR (x);
  482.   /* If the increment has happened and a pre-increment copy exists,
  483.      use that copy.  */
  484.   if (QUEUED_COPY (x) != 0)
  485.     return QUEUED_COPY (x);
  486.   /* The increment has happened but we haven't set up a pre-increment copy.
  487.      Set one up now, and use it.  */
  488.   QUEUED_COPY (x) = gen_reg_rtx (GET_MODE (QUEUED_VAR (x)));
  489.   emit_insn_before (gen_move_insn (QUEUED_COPY (x), QUEUED_VAR (x)),
  490.             QUEUED_INSN (x));
  491.   return QUEUED_COPY (x);
  492. }
  493.  
  494. /* Return nonzero if X contains a QUEUED expression:
  495.    if it contains anything that will be altered by a queued increment.
  496.    We handle only combinations of MEM, PLUS, MINUS and MULT operators
  497.    since memory addresses generally contain only those.  */
  498.  
  499. static int
  500. queued_subexp_p (x)
  501.      rtx x;
  502. {
  503.   register enum rtx_code code = GET_CODE (x);
  504.   switch (code)
  505.     {
  506.     case QUEUED:
  507.       return 1;
  508.     case MEM:
  509.       return queued_subexp_p (XEXP (x, 0));
  510.     case MULT:
  511.     case PLUS:
  512.     case MINUS:
  513.       return queued_subexp_p (XEXP (x, 0))
  514.     || queued_subexp_p (XEXP (x, 1));
  515.     }
  516.   return 0;
  517. }
  518.  
  519. /* Perform all the pending incrementations.  */
  520.  
  521. void
  522. emit_queue ()
  523. {
  524.   register rtx p;
  525.   while (p = pending_chain)
  526.     {
  527.       QUEUED_INSN (p) = emit_insn (QUEUED_BODY (p));
  528.       pending_chain = QUEUED_NEXT (p);
  529.     }
  530. }
  531.  
  532. static void
  533. init_queue ()
  534. {
  535.   if (pending_chain)
  536.     abort ();
  537. }
  538.  
  539. /* Copy data from FROM to TO, where the machine modes are not the same.
  540.    Both modes may be integer, or both may be floating.
  541.    UNSIGNEDP should be nonzero if FROM is an unsigned type.
  542.    This causes zero-extension instead of sign-extension.  */
  543.  
  544. void
  545. convert_move (to, from, unsignedp)
  546.      register rtx to, from;
  547.      int unsignedp;
  548. {
  549.   enum machine_mode to_mode = GET_MODE (to);
  550.   enum machine_mode from_mode = GET_MODE (from);
  551.   int to_real = GET_MODE_CLASS (to_mode) == MODE_FLOAT;
  552.   int from_real = GET_MODE_CLASS (from_mode) == MODE_FLOAT;
  553.   enum insn_code code;
  554.   rtx libcall;
  555.  
  556.   /* rtx code for making an equivalent value.  */
  557.   enum rtx_code equiv_code = (unsignedp ? ZERO_EXTEND : SIGN_EXTEND);
  558.  
  559.   to = protect_from_queue (to, 1);
  560.   from = protect_from_queue (from, 0);
  561.  
  562.   if (to_real != from_real)
  563.     abort ();
  564.  
  565.   /* If FROM is a SUBREG that indicates that we have already done at least
  566.      the required extension, strip it.  We don't handle such SUBREGs as
  567.      TO here.  */
  568.  
  569.   if (GET_CODE (from) == SUBREG && SUBREG_PROMOTED_VAR_P (from)
  570.       && (GET_MODE_SIZE (GET_MODE (SUBREG_REG (from)))
  571.       >= GET_MODE_SIZE (to_mode))
  572.       && SUBREG_PROMOTED_UNSIGNED_P (from) == unsignedp)
  573.     from = gen_lowpart (to_mode, from), from_mode = to_mode;
  574.  
  575.   if (GET_CODE (to) == SUBREG && SUBREG_PROMOTED_VAR_P (to))
  576.     abort ();
  577.  
  578.   if (to_mode == from_mode
  579.       || (from_mode == VOIDmode && CONSTANT_P (from)))
  580.     {
  581.       emit_move_insn (to, from);
  582.       return;
  583.     }
  584.  
  585.   if (to_real)
  586.     {
  587.       rtx value;
  588.  
  589. #ifdef HAVE_extendqfhf2
  590.       if (HAVE_extendqfsf2 && from_mode == QFmode && to_mode == HFmode)
  591.     {
  592.       emit_unop_insn (CODE_FOR_extendqfsf2, to, from, UNKNOWN);
  593.       return;
  594.     }
  595. #endif
  596. #ifdef HAVE_extendqfsf2
  597.       if (HAVE_extendqfsf2 && from_mode == QFmode && to_mode == SFmode)
  598.     {
  599.       emit_unop_insn (CODE_FOR_extendqfsf2, to, from, UNKNOWN);
  600.       return;
  601.     }
  602. #endif
  603. #ifdef HAVE_extendqfdf2
  604.       if (HAVE_extendqfdf2 && from_mode == QFmode && to_mode == DFmode)
  605.     {
  606.       emit_unop_insn (CODE_FOR_extendqfdf2, to, from, UNKNOWN);
  607.       return;
  608.     }
  609. #endif
  610. #ifdef HAVE_extendqfxf2
  611.       if (HAVE_extendqfxf2 && from_mode == QFmode && to_mode == XFmode)
  612.     {
  613.       emit_unop_insn (CODE_FOR_extendqfxf2, to, from, UNKNOWN);
  614.       return;
  615.     }
  616. #endif
  617. #ifdef HAVE_extendqftf2
  618.       if (HAVE_extendqftf2 && from_mode == QFmode && to_mode == TFmode)
  619.     {
  620.       emit_unop_insn (CODE_FOR_extendqftf2, to, from, UNKNOWN);
  621.       return;
  622.     }
  623. #endif
  624.  
  625. #ifdef HAVE_extendhftqf2
  626.       if (HAVE_extendhftqf2 && from_mode == HFmode && to_mode == TQFmode)
  627.     {
  628.       emit_unop_insn (CODE_FOR_extendhftqf2, to, from, UNKNOWN);
  629.       return;
  630.     }
  631. #endif
  632.  
  633. #ifdef HAVE_extendhfsf2
  634.       if (HAVE_extendhfsf2 && from_mode == HFmode && to_mode == SFmode)
  635.     {
  636.       emit_unop_insn (CODE_FOR_extendhfsf2, to, from, UNKNOWN);
  637.       return;
  638.     }
  639. #endif
  640. #ifdef HAVE_extendhfdf2
  641.       if (HAVE_extendhfdf2 && from_mode == HFmode && to_mode == DFmode)
  642.     {
  643.       emit_unop_insn (CODE_FOR_extendhfdf2, to, from, UNKNOWN);
  644.       return;
  645.     }
  646. #endif
  647. #ifdef HAVE_extendhfxf2
  648.       if (HAVE_extendhfxf2 && from_mode == HFmode && to_mode == XFmode)
  649.     {
  650.       emit_unop_insn (CODE_FOR_extendhfxf2, to, from, UNKNOWN);
  651.       return;
  652.     }
  653. #endif
  654. #ifdef HAVE_extendhftf2
  655.       if (HAVE_extendhftf2 && from_mode == HFmode && to_mode == TFmode)
  656.     {
  657.       emit_unop_insn (CODE_FOR_extendhftf2, to, from, UNKNOWN);
  658.       return;
  659.     }
  660. #endif
  661.  
  662. #ifdef HAVE_extendsfdf2
  663.       if (HAVE_extendsfdf2 && from_mode == SFmode && to_mode == DFmode)
  664.     {
  665.       emit_unop_insn (CODE_FOR_extendsfdf2, to, from, UNKNOWN);
  666.       return;
  667.     }
  668. #endif
  669. #ifdef HAVE_extendsfxf2
  670.       if (HAVE_extendsfxf2 && from_mode == SFmode && to_mode == XFmode)
  671.     {
  672.       emit_unop_insn (CODE_FOR_extendsfxf2, to, from, UNKNOWN);
  673.       return;
  674.     }
  675. #endif
  676. #ifdef HAVE_extendsftf2
  677.       if (HAVE_extendsftf2 && from_mode == SFmode && to_mode == TFmode)
  678.     {
  679.       emit_unop_insn (CODE_FOR_extendsftf2, to, from, UNKNOWN);
  680.       return;
  681.     }
  682. #endif
  683. #ifdef HAVE_extenddfxf2
  684.       if (HAVE_extenddfxf2 && from_mode == DFmode && to_mode == XFmode)
  685.     {
  686.       emit_unop_insn (CODE_FOR_extenddfxf2, to, from, UNKNOWN);
  687.       return;
  688.     }
  689. #endif
  690. #ifdef HAVE_extenddftf2
  691.       if (HAVE_extenddftf2 && from_mode == DFmode && to_mode == TFmode)
  692.     {
  693.       emit_unop_insn (CODE_FOR_extenddftf2, to, from, UNKNOWN);
  694.       return;
  695.     }
  696. #endif
  697.  
  698. #ifdef HAVE_trunchfqf2
  699.       if (HAVE_trunchfqf2 && from_mode == HFmode && to_mode == QFmode)
  700.     {
  701.       emit_unop_insn (CODE_FOR_trunchfqf2, to, from, UNKNOWN);
  702.       return;
  703.     }
  704. #endif
  705. #ifdef HAVE_truncsfqf2
  706.       if (HAVE_truncsfqf2 && from_mode == SFmode && to_mode == QFmode)
  707.     {
  708.       emit_unop_insn (CODE_FOR_truncsfqf2, to, from, UNKNOWN);
  709.       return;
  710.     }
  711. #endif
  712. #ifdef HAVE_truncdfqf2
  713.       if (HAVE_truncdfqf2 && from_mode == DFmode && to_mode == QFmode)
  714.     {
  715.       emit_unop_insn (CODE_FOR_truncdfqf2, to, from, UNKNOWN);
  716.       return;
  717.     }
  718. #endif
  719. #ifdef HAVE_truncxfqf2
  720.       if (HAVE_truncxfqf2 && from_mode == XFmode && to_mode == QFmode)
  721.     {
  722.       emit_unop_insn (CODE_FOR_truncxfqf2, to, from, UNKNOWN);
  723.       return;
  724.     }
  725. #endif
  726. #ifdef HAVE_trunctfqf2
  727.       if (HAVE_trunctfqf2 && from_mode == TFmode && to_mode == QFmode)
  728.     {
  729.       emit_unop_insn (CODE_FOR_trunctfqf2, to, from, UNKNOWN);
  730.       return;
  731.     }
  732. #endif
  733.  
  734. #ifdef HAVE_trunctqfhf2
  735.       if (HAVE_trunctqfhf2 && from_mode == TQFmode && to_mode == HFmode)
  736.     {
  737.       emit_unop_insn (CODE_FOR_trunctqfhf2, to, from, UNKNOWN);
  738.       return;
  739.     }
  740. #endif
  741. #ifdef HAVE_truncsfhf2
  742.       if (HAVE_truncsfhf2 && from_mode == SFmode && to_mode == HFmode)
  743.     {
  744.       emit_unop_insn (CODE_FOR_truncsfhf2, to, from, UNKNOWN);
  745.       return;
  746.     }
  747. #endif
  748. #ifdef HAVE_truncdfhf2
  749.       if (HAVE_truncdfhf2 && from_mode == DFmode && to_mode == HFmode)
  750.     {
  751.       emit_unop_insn (CODE_FOR_truncdfhf2, to, from, UNKNOWN);
  752.       return;
  753.     }
  754. #endif
  755. #ifdef HAVE_truncxfhf2
  756.       if (HAVE_truncxfhf2 && from_mode == XFmode && to_mode == HFmode)
  757.     {
  758.       emit_unop_insn (CODE_FOR_truncxfhf2, to, from, UNKNOWN);
  759.       return;
  760.     }
  761. #endif
  762. #ifdef HAVE_trunctfhf2
  763.       if (HAVE_trunctfhf2 && from_mode == TFmode && to_mode == HFmode)
  764.     {
  765.       emit_unop_insn (CODE_FOR_trunctfhf2, to, from, UNKNOWN);
  766.       return;
  767.     }
  768. #endif
  769. #ifdef HAVE_truncdfsf2
  770.       if (HAVE_truncdfsf2 && from_mode == DFmode && to_mode == SFmode)
  771.     {
  772.       emit_unop_insn (CODE_FOR_truncdfsf2, to, from, UNKNOWN);
  773.       return;
  774.     }
  775. #endif
  776. #ifdef HAVE_truncxfsf2
  777.       if (HAVE_truncxfsf2 && from_mode == XFmode && to_mode == SFmode)
  778.     {
  779.       emit_unop_insn (CODE_FOR_truncxfsf2, to, from, UNKNOWN);
  780.       return;
  781.     }
  782. #endif
  783. #ifdef HAVE_trunctfsf2
  784.       if (HAVE_trunctfsf2 && from_mode == TFmode && to_mode == SFmode)
  785.     {
  786.       emit_unop_insn (CODE_FOR_trunctfsf2, to, from, UNKNOWN);
  787.       return;
  788.     }
  789. #endif
  790. #ifdef HAVE_truncxfdf2
  791.       if (HAVE_truncxfdf2 && from_mode == XFmode && to_mode == DFmode)
  792.     {
  793.       emit_unop_insn (CODE_FOR_truncxfdf2, to, from, UNKNOWN);
  794.       return;
  795.     }
  796. #endif
  797. #ifdef HAVE_trunctfdf2
  798.       if (HAVE_trunctfdf2 && from_mode == TFmode && to_mode == DFmode)
  799.     {
  800.       emit_unop_insn (CODE_FOR_trunctfdf2, to, from, UNKNOWN);
  801.       return;
  802.     }
  803. #endif
  804.  
  805.       libcall = (rtx) 0;
  806.       switch (from_mode)
  807.     {
  808.     case SFmode:
  809.       switch (to_mode)
  810.         {
  811.         case DFmode:
  812.           libcall = extendsfdf2_libfunc;
  813.           break;
  814.  
  815.         case XFmode:
  816.           libcall = extendsfxf2_libfunc;
  817.           break;
  818.  
  819.         case TFmode:
  820.           libcall = extendsftf2_libfunc;
  821.           break;
  822.         }
  823.       break;
  824.  
  825.     case DFmode:
  826.       switch (to_mode)
  827.         {
  828.         case SFmode:
  829.           libcall = truncdfsf2_libfunc;
  830.           break;
  831.  
  832.         case XFmode:
  833.           libcall = extenddfxf2_libfunc;
  834.           break;
  835.  
  836.         case TFmode:
  837.           libcall = extenddftf2_libfunc;
  838.           break;
  839.         }
  840.       break;
  841.  
  842.     case XFmode:
  843.       switch (to_mode)
  844.         {
  845.         case SFmode:
  846.           libcall = truncxfsf2_libfunc;
  847.           break;
  848.  
  849.         case DFmode:
  850.           libcall = truncxfdf2_libfunc;
  851.           break;
  852.         }
  853.       break;
  854.  
  855.     case TFmode:
  856.       switch (to_mode)
  857.         {
  858.         case SFmode:
  859.           libcall = trunctfsf2_libfunc;
  860.           break;
  861.  
  862.         case DFmode:
  863.           libcall = trunctfdf2_libfunc;
  864.           break;
  865.         }
  866.       break;
  867.     }
  868.  
  869.       if (libcall == (rtx) 0)
  870.     /* This conversion is not implemented yet.  */
  871.     abort ();
  872.  
  873.       value = emit_library_call_value (libcall, NULL_RTX, 1, to_mode,
  874.                        1, from, from_mode);
  875.       emit_move_insn (to, value);
  876.       return;
  877.     }
  878.  
  879.   /* Now both modes are integers.  */
  880.  
  881.   /* Handle expanding beyond a word.  */
  882.   if (GET_MODE_BITSIZE (from_mode) < GET_MODE_BITSIZE (to_mode)
  883.       && GET_MODE_BITSIZE (to_mode) > BITS_PER_WORD)
  884.     {
  885.       rtx insns;
  886.       rtx lowpart;
  887.       rtx fill_value;
  888.       rtx lowfrom;
  889.       int i;
  890.       enum machine_mode lowpart_mode;
  891.       int nwords = CEIL (GET_MODE_SIZE (to_mode), UNITS_PER_WORD);
  892.  
  893.       /* Try converting directly if the insn is supported.  */
  894.       if ((code = can_extend_p (to_mode, from_mode, unsignedp))
  895.       != CODE_FOR_nothing)
  896.     {
  897.       /* If FROM is a SUBREG, put it into a register.  Do this
  898.          so that we always generate the same set of insns for
  899.          better cse'ing; if an intermediate assignment occurred,
  900.          we won't be doing the operation directly on the SUBREG.  */
  901.       if (optimize > 0 && GET_CODE (from) == SUBREG)
  902.         from = force_reg (from_mode, from);
  903.       emit_unop_insn (code, to, from, equiv_code);
  904.       return;
  905.     }
  906.       /* Next, try converting via full word.  */
  907.       else if (GET_MODE_BITSIZE (from_mode) < BITS_PER_WORD
  908.            && ((code = can_extend_p (to_mode, word_mode, unsignedp))
  909.            != CODE_FOR_nothing))
  910.     {
  911.       if (GET_CODE (to) == REG)
  912.         emit_insn (gen_rtx (CLOBBER, VOIDmode, to));
  913.       convert_move (gen_lowpart (word_mode, to), from, unsignedp);
  914.       emit_unop_insn (code, to,
  915.               gen_lowpart (word_mode, to), equiv_code);
  916.       return;
  917.     }
  918.  
  919.       /* No special multiword conversion insn; do it by hand.  */
  920.       start_sequence ();
  921.  
  922.       /* Since we will turn this into a no conflict block, we must ensure
  923.      that the source does not overlap the target.  */
  924.  
  925.       if (reg_overlap_mentioned_p (to, from))
  926.     from = force_reg (from_mode, from);
  927.  
  928.       /* Get a copy of FROM widened to a word, if necessary.  */
  929.       if (GET_MODE_BITSIZE (from_mode) < BITS_PER_WORD)
  930.     lowpart_mode = word_mode;
  931.       else
  932.     lowpart_mode = from_mode;
  933.  
  934.       lowfrom = convert_to_mode (lowpart_mode, from, unsignedp);
  935.  
  936.       lowpart = gen_lowpart (lowpart_mode, to);
  937.       emit_move_insn (lowpart, lowfrom);
  938.  
  939.       /* Compute the value to put in each remaining word.  */
  940.       if (unsignedp)
  941.     fill_value = const0_rtx;
  942.       else
  943.     {
  944. #ifdef HAVE_slt
  945.       if (HAVE_slt
  946.           && insn_operand_mode[(int) CODE_FOR_slt][0] == word_mode
  947.           && STORE_FLAG_VALUE == -1)
  948.         {
  949.           emit_cmp_insn (lowfrom, const0_rtx, NE, NULL_RTX,
  950.                  lowpart_mode, 0, 0);
  951.           fill_value = gen_reg_rtx (word_mode);
  952.           emit_insn (gen_slt (fill_value));
  953.         }
  954.       else
  955. #endif
  956.         {
  957.           fill_value
  958.         = expand_shift (RSHIFT_EXPR, lowpart_mode, lowfrom,
  959.                 size_int (GET_MODE_BITSIZE (lowpart_mode) - 1),
  960.                 NULL_RTX, 0);
  961.           fill_value = convert_to_mode (word_mode, fill_value, 1);
  962.         }
  963.     }
  964.  
  965.       /* Fill the remaining words.  */
  966.       for (i = GET_MODE_SIZE (lowpart_mode) / UNITS_PER_WORD; i < nwords; i++)
  967.     {
  968.       int index = (WORDS_BIG_ENDIAN ? nwords - i - 1 : i);
  969.       rtx subword = operand_subword (to, index, 1, to_mode);
  970.  
  971.       if (subword == 0)
  972.         abort ();
  973.  
  974.       if (fill_value != subword)
  975.         emit_move_insn (subword, fill_value);
  976.     }
  977.  
  978.       insns = get_insns ();
  979.       end_sequence ();
  980.  
  981.       emit_no_conflict_block (insns, to, from, NULL_RTX,
  982.                   gen_rtx (equiv_code, to_mode, copy_rtx (from)));
  983.       return;
  984.     }
  985.  
  986.   /* Truncating multi-word to a word or less.  */
  987.   if (GET_MODE_BITSIZE (from_mode) > BITS_PER_WORD
  988.       && GET_MODE_BITSIZE (to_mode) <= BITS_PER_WORD)
  989.     {
  990.       if (!((GET_CODE (from) == MEM
  991.          && ! MEM_VOLATILE_P (from)
  992.          && direct_load[(int) to_mode]
  993.          && ! mode_dependent_address_p (XEXP (from, 0)))
  994.         || GET_CODE (from) == REG
  995.         || GET_CODE (from) == SUBREG))
  996.     from = force_reg (from_mode, from);
  997.       convert_move (to, gen_lowpart (word_mode, from), 0);
  998.       return;
  999.     }
  1000.  
  1001.   /* Handle pointer conversion */            /* SPEE 900220 */
  1002.   if (to_mode == PSImode)
  1003.     {
  1004.       if (from_mode != SImode)
  1005.     from = convert_to_mode (SImode, from, unsignedp);
  1006.  
  1007. #ifdef HAVE_truncsipsi2
  1008.       if (HAVE_truncsipsi2)
  1009.     {
  1010.       emit_unop_insn (CODE_FOR_truncsipsi2, to, from, UNKNOWN);
  1011.       return;
  1012.     }
  1013. #endif /* HAVE_truncsipsi2 */
  1014.       abort ();
  1015.     }
  1016.  
  1017.   if (from_mode == PSImode)
  1018.     {
  1019.       if (to_mode != SImode)
  1020.     {
  1021.       from = convert_to_mode (SImode, from, unsignedp);
  1022.       from_mode = SImode;
  1023.     }
  1024.       else
  1025.     {
  1026. #ifdef HAVE_extendpsisi2
  1027.       if (HAVE_extendpsisi2)
  1028.         {
  1029.           emit_unop_insn (CODE_FOR_extendpsisi2, to, from, UNKNOWN);
  1030.           return;
  1031.         }
  1032. #endif /* HAVE_extendpsisi2 */
  1033.       abort ();
  1034.     }
  1035.     }
  1036.  
  1037.   if (to_mode == PDImode)
  1038.     {
  1039.       if (from_mode != DImode)
  1040.     from = convert_to_mode (DImode, from, unsignedp);
  1041.  
  1042. #ifdef HAVE_truncdipdi2
  1043.       if (HAVE_truncdipdi2)
  1044.     {
  1045.       emit_unop_insn (CODE_FOR_truncdipdi2, to, from, UNKNOWN);
  1046.       return;
  1047.     }
  1048. #endif /* HAVE_truncdipdi2 */
  1049.       abort ();
  1050.     }
  1051.  
  1052.   if (from_mode == PDImode)
  1053.     {
  1054.       if (to_mode != DImode)
  1055.     {
  1056.       from = convert_to_mode (DImode, from, unsignedp);
  1057.       from_mode = DImode;
  1058.     }
  1059.       else
  1060.     {
  1061. #ifdef HAVE_extendpdidi2
  1062.       if (HAVE_extendpdidi2)
  1063.         {
  1064.           emit_unop_insn (CODE_FOR_extendpdidi2, to, from, UNKNOWN);
  1065.           return;
  1066.         }
  1067. #endif /* HAVE_extendpdidi2 */
  1068.       abort ();
  1069.     }
  1070.     }
  1071.  
  1072.   /* Now follow all the conversions between integers
  1073.      no more than a word long.  */
  1074.  
  1075.   /* For truncation, usually we can just refer to FROM in a narrower mode.  */
  1076.   if (GET_MODE_BITSIZE (to_mode) < GET_MODE_BITSIZE (from_mode)
  1077.       && TRULY_NOOP_TRUNCATION (GET_MODE_BITSIZE (to_mode),
  1078.                 GET_MODE_BITSIZE (from_mode)))
  1079.     {
  1080.       if (!((GET_CODE (from) == MEM
  1081.          && ! MEM_VOLATILE_P (from)
  1082.          && direct_load[(int) to_mode]
  1083.          && ! mode_dependent_address_p (XEXP (from, 0)))
  1084.         || GET_CODE (from) == REG
  1085.         || GET_CODE (from) == SUBREG))
  1086.     from = force_reg (from_mode, from);
  1087.       if (GET_CODE (from) == REG && REGNO (from) < FIRST_PSEUDO_REGISTER
  1088.       && ! HARD_REGNO_MODE_OK (REGNO (from), to_mode))
  1089.     from = copy_to_reg (from);
  1090.       emit_move_insn (to, gen_lowpart (to_mode, from));
  1091.       return;
  1092.     }
  1093.  
  1094.   /* Handle extension.  */
  1095.   if (GET_MODE_BITSIZE (to_mode) > GET_MODE_BITSIZE (from_mode))
  1096.     {
  1097.       /* Convert directly if that works.  */
  1098.       if ((code = can_extend_p (to_mode, from_mode, unsignedp))
  1099.       != CODE_FOR_nothing)
  1100.     {
  1101.       emit_unop_insn (code, to, from, equiv_code);
  1102.       return;
  1103.     }
  1104.       else
  1105.     {
  1106.       enum machine_mode intermediate;
  1107.  
  1108.       /* Search for a mode to convert via.  */
  1109.       for (intermediate = from_mode; intermediate != VOIDmode;
  1110.            intermediate = GET_MODE_WIDER_MODE (intermediate))
  1111.         if (((can_extend_p (to_mode, intermediate, unsignedp)
  1112.           != CODE_FOR_nothing)
  1113.          || (GET_MODE_SIZE (to_mode) < GET_MODE_SIZE (intermediate)
  1114.              && TRULY_NOOP_TRUNCATION (to_mode, intermediate)))
  1115.         && (can_extend_p (intermediate, from_mode, unsignedp)
  1116.             != CODE_FOR_nothing))
  1117.           {
  1118.         convert_move (to, convert_to_mode (intermediate, from,
  1119.                            unsignedp), unsignedp);
  1120.         return;
  1121.           }
  1122.  
  1123.       /* No suitable intermediate mode.  */
  1124.       abort ();
  1125.     }
  1126.     }
  1127.  
  1128.   /* Support special truncate insns for certain modes.  */ 
  1129.  
  1130.   if (from_mode == DImode && to_mode == SImode)
  1131.     {
  1132. #ifdef HAVE_truncdisi2
  1133.       if (HAVE_truncdisi2)
  1134.     {
  1135.       emit_unop_insn (CODE_FOR_truncdisi2, to, from, UNKNOWN);
  1136.       return;
  1137.     }
  1138. #endif
  1139.       convert_move (to, force_reg (from_mode, from), unsignedp);
  1140.       return;
  1141.     }
  1142.  
  1143.   if (from_mode == DImode && to_mode == HImode)
  1144.     {
  1145. #ifdef HAVE_truncdihi2
  1146.       if (HAVE_truncdihi2)
  1147.     {
  1148.       emit_unop_insn (CODE_FOR_truncdihi2, to, from, UNKNOWN);
  1149.       return;
  1150.     }
  1151. #endif
  1152.       convert_move (to, force_reg (from_mode, from), unsignedp);
  1153.       return;
  1154.     }
  1155.  
  1156.   if (from_mode == DImode && to_mode == QImode)
  1157.     {
  1158. #ifdef HAVE_truncdiqi2
  1159.       if (HAVE_truncdiqi2)
  1160.     {
  1161.       emit_unop_insn (CODE_FOR_truncdiqi2, to, from, UNKNOWN);
  1162.       return;
  1163.     }
  1164. #endif
  1165.       convert_move (to, force_reg (from_mode, from), unsignedp);
  1166.       return;
  1167.     }
  1168.  
  1169.   if (from_mode == SImode && to_mode == HImode)
  1170.     {
  1171. #ifdef HAVE_truncsihi2
  1172.       if (HAVE_truncsihi2)
  1173.     {
  1174.       emit_unop_insn (CODE_FOR_truncsihi2, to, from, UNKNOWN);
  1175.       return;
  1176.     }
  1177. #endif
  1178.       convert_move (to, force_reg (from_mode, from), unsignedp);
  1179.       return;
  1180.     }
  1181.  
  1182.   if (from_mode == SImode && to_mode == QImode)
  1183.     {
  1184. #ifdef HAVE_truncsiqi2
  1185.       if (HAVE_truncsiqi2)
  1186.     {
  1187.       emit_unop_insn (CODE_FOR_truncsiqi2, to, from, UNKNOWN);
  1188.       return;
  1189.     }
  1190. #endif
  1191.       convert_move (to, force_reg (from_mode, from), unsignedp);
  1192.       return;
  1193.     }
  1194.  
  1195.   if (from_mode == HImode && to_mode == QImode)
  1196.     {
  1197. #ifdef HAVE_trunchiqi2
  1198.       if (HAVE_trunchiqi2)
  1199.     {
  1200.       emit_unop_insn (CODE_FOR_trunchiqi2, to, from, UNKNOWN);
  1201.       return;
  1202.     }
  1203. #endif
  1204.       convert_move (to, force_reg (from_mode, from), unsignedp);
  1205.       return;
  1206.     }
  1207.  
  1208.   if (from_mode == TImode && to_mode == DImode)
  1209.     {
  1210. #ifdef HAVE_trunctidi2
  1211.       if (HAVE_trunctidi2)
  1212.     {
  1213.       emit_unop_insn (CODE_FOR_trunctidi2, to, from, UNKNOWN);
  1214.       return;
  1215.     }
  1216. #endif
  1217.       convert_move (to, force_reg (from_mode, from), unsignedp);
  1218.       return;
  1219.     }
  1220.  
  1221.   if (from_mode == TImode && to_mode == SImode)
  1222.     {
  1223. #ifdef HAVE_trunctisi2
  1224.       if (HAVE_trunctisi2)
  1225.     {
  1226.       emit_unop_insn (CODE_FOR_trunctisi2, to, from, UNKNOWN);
  1227.       return;
  1228.     }
  1229. #endif
  1230.       convert_move (to, force_reg (from_mode, from), unsignedp);
  1231.       return;
  1232.     }
  1233.  
  1234.   if (from_mode == TImode && to_mode == HImode)
  1235.     {
  1236. #ifdef HAVE_trunctihi2
  1237.       if (HAVE_trunctihi2)
  1238.     {
  1239.       emit_unop_insn (CODE_FOR_trunctihi2, to, from, UNKNOWN);
  1240.       return;
  1241.     }
  1242. #endif
  1243.       convert_move (to, force_reg (from_mode, from), unsignedp);
  1244.       return;
  1245.     }
  1246.  
  1247.   if (from_mode == TImode && to_mode == QImode)
  1248.     {
  1249. #ifdef HAVE_trunctiqi2
  1250.       if (HAVE_trunctiqi2)
  1251.     {
  1252.       emit_unop_insn (CODE_FOR_trunctiqi2, to, from, UNKNOWN);
  1253.       return;
  1254.     }
  1255. #endif
  1256.       convert_move (to, force_reg (from_mode, from), unsignedp);
  1257.       return;
  1258.     }
  1259.  
  1260.   /* Handle truncation of volatile memrefs, and so on;
  1261.      the things that couldn't be truncated directly,
  1262.      and for which there was no special instruction.  */
  1263.   if (GET_MODE_BITSIZE (to_mode) < GET_MODE_BITSIZE (from_mode))
  1264.     {
  1265.       rtx temp = force_reg (to_mode, gen_lowpart (to_mode, from));
  1266.       emit_move_insn (to, temp);
  1267.       return;
  1268.     }
  1269.  
  1270.   /* Mode combination is not recognized.  */
  1271.   abort ();
  1272. }
  1273.  
  1274. /* Return an rtx for a value that would result
  1275.    from converting X to mode MODE.
  1276.    Both X and MODE may be floating, or both integer.
  1277.    UNSIGNEDP is nonzero if X is an unsigned value.
  1278.    This can be done by referring to a part of X in place
  1279.    or by copying to a new temporary with conversion.
  1280.  
  1281.    This function *must not* call protect_from_queue
  1282.    except when putting X into an insn (in which case convert_move does it).  */
  1283.  
  1284. rtx
  1285. convert_to_mode (mode, x, unsignedp)
  1286.      enum machine_mode mode;
  1287.      rtx x;
  1288.      int unsignedp;
  1289. {
  1290.   return convert_modes (mode, VOIDmode, x, unsignedp);
  1291. }
  1292.  
  1293. /* Return an rtx for a value that would result
  1294.    from converting X from mode OLDMODE to mode MODE.
  1295.    Both modes may be floating, or both integer.
  1296.    UNSIGNEDP is nonzero if X is an unsigned value.
  1297.  
  1298.    This can be done by referring to a part of X in place
  1299.    or by copying to a new temporary with conversion.
  1300.  
  1301.    You can give VOIDmode for OLDMODE, if you are sure X has a nonvoid mode.
  1302.  
  1303.    This function *must not* call protect_from_queue
  1304.    except when putting X into an insn (in which case convert_move does it).  */
  1305.  
  1306. rtx
  1307. convert_modes (mode, oldmode, x, unsignedp)
  1308.      enum machine_mode mode, oldmode;
  1309.      rtx x;
  1310.      int unsignedp;
  1311. {
  1312.   register rtx temp;
  1313.  
  1314.   /* If FROM is a SUBREG that indicates that we have already done at least
  1315.      the required extension, strip it.  */
  1316.  
  1317.   if (GET_CODE (x) == SUBREG && SUBREG_PROMOTED_VAR_P (x)
  1318.       && GET_MODE_SIZE (GET_MODE (SUBREG_REG (x))) >= GET_MODE_SIZE (mode)
  1319.       && SUBREG_PROMOTED_UNSIGNED_P (x) == unsignedp)
  1320.     x = gen_lowpart (mode, x);
  1321.  
  1322.   if (GET_MODE (x) != VOIDmode)
  1323.     oldmode = GET_MODE (x);
  1324.  
  1325.   if (mode == oldmode)
  1326.     return x;
  1327.  
  1328.   /* There is one case that we must handle specially: If we are converting
  1329.      a CONST_INT into a mode whose size is twice HOST_BITS_PER_WIDE_INT and
  1330.      we are to interpret the constant as unsigned, gen_lowpart will do
  1331.      the wrong if the constant appears negative.  What we want to do is
  1332.      make the high-order word of the constant zero, not all ones.  */
  1333.  
  1334.   if (unsignedp && GET_MODE_CLASS (mode) == MODE_INT
  1335.       && GET_MODE_BITSIZE (mode) == 2 * HOST_BITS_PER_WIDE_INT
  1336.       && GET_CODE (x) == CONST_INT && INTVAL (x) < 0)
  1337.     return immed_double_const (INTVAL (x), (HOST_WIDE_INT) 0, mode);
  1338.  
  1339.   /* We can do this with a gen_lowpart if both desired and current modes
  1340.      are integer, and this is either a constant integer, a register, or a
  1341.      non-volatile MEM.  Except for the constant case where MODE is no
  1342.      wider than HOST_BITS_PER_WIDE_INT, we must be narrowing the operand.  */
  1343.  
  1344.   if ((GET_CODE (x) == CONST_INT
  1345.        && GET_MODE_BITSIZE (mode) <= HOST_BITS_PER_WIDE_INT)
  1346.       || (GET_MODE_CLASS (mode) == MODE_INT
  1347.       && GET_MODE_CLASS (oldmode) == MODE_INT
  1348.       && (GET_CODE (x) == CONST_DOUBLE
  1349.           || (GET_MODE_SIZE (mode) <= GET_MODE_SIZE (oldmode)
  1350.           && ((GET_CODE (x) == MEM && ! MEM_VOLATILE_P (x)
  1351.                && direct_load[(int) mode])
  1352.               || (GET_CODE (x) == REG
  1353.               && TRULY_NOOP_TRUNCATION (GET_MODE_BITSIZE (mode),
  1354.                             GET_MODE_BITSIZE (GET_MODE (x)))))))))
  1355.     {
  1356.       /* ?? If we don't know OLDMODE, we have to assume here that
  1357.      X does not need sign- or zero-extension.   This may not be
  1358.      the case, but it's the best we can do.  */
  1359.       if (GET_CODE (x) == CONST_INT && oldmode != VOIDmode
  1360.       && GET_MODE_SIZE (mode) > GET_MODE_SIZE (oldmode))
  1361.     {
  1362.       HOST_WIDE_INT val = INTVAL (x);
  1363.       int width = GET_MODE_BITSIZE (oldmode);
  1364.  
  1365.       /* We must sign or zero-extend in this case.  Start by
  1366.          zero-extending, then sign extend if we need to.  */
  1367.       val &= ((HOST_WIDE_INT) 1 << width) - 1;
  1368.       if (! unsignedp
  1369.           && (val & ((HOST_WIDE_INT) 1 << (width - 1))))
  1370.         val |= (HOST_WIDE_INT) (-1) << width;
  1371.  
  1372.       return GEN_INT (val);
  1373.     }
  1374.  
  1375.       return gen_lowpart (mode, x);
  1376.     }
  1377.  
  1378.   temp = gen_reg_rtx (mode);
  1379.   convert_move (temp, x, unsignedp);
  1380.   return temp;
  1381. }
  1382.  
  1383. /* Generate several move instructions to copy LEN bytes
  1384.    from block FROM to block TO.  (These are MEM rtx's with BLKmode).
  1385.    The caller must pass FROM and TO
  1386.     through protect_from_queue before calling.
  1387.    ALIGN (in bytes) is maximum alignment we can assume.  */
  1388.  
  1389. static void
  1390. move_by_pieces (to, from, len, align)
  1391.      rtx to, from;
  1392.      int len, align;
  1393. {
  1394.   struct move_by_pieces data;
  1395.   rtx to_addr = XEXP (to, 0), from_addr = XEXP (from, 0);
  1396.   int max_size = MOVE_MAX + 1;
  1397.  
  1398.   data.offset = 0;
  1399.   data.to_addr = to_addr;
  1400.   data.from_addr = from_addr;
  1401.   data.to = to;
  1402.   data.from = from;
  1403.   data.autinc_to
  1404.     = (GET_CODE (to_addr) == PRE_INC || GET_CODE (to_addr) == PRE_DEC
  1405.        || GET_CODE (to_addr) == POST_INC || GET_CODE (to_addr) == POST_DEC);
  1406.   data.autinc_from
  1407.     = (GET_CODE (from_addr) == PRE_INC || GET_CODE (from_addr) == PRE_DEC
  1408.        || GET_CODE (from_addr) == POST_INC
  1409.        || GET_CODE (from_addr) == POST_DEC);
  1410.  
  1411.   data.explicit_inc_from = 0;
  1412.   data.explicit_inc_to = 0;
  1413.   data.reverse
  1414.     = (GET_CODE (to_addr) == PRE_DEC || GET_CODE (to_addr) == POST_DEC);
  1415.   if (data.reverse) data.offset = len;
  1416.   data.len = len;
  1417.  
  1418.   data.to_struct = MEM_IN_STRUCT_P (to);
  1419.   data.from_struct = MEM_IN_STRUCT_P (from);
  1420.  
  1421.   /* If copying requires more than two move insns,
  1422.      copy addresses to registers (to make displacements shorter)
  1423.      and use post-increment if available.  */
  1424.   if (!(data.autinc_from && data.autinc_to)
  1425.       && move_by_pieces_ninsns (len, align) > 2)
  1426.     {
  1427. #ifdef HAVE_PRE_DECREMENT
  1428.       if (data.reverse && ! data.autinc_from)
  1429.     {
  1430.       data.from_addr = copy_addr_to_reg (plus_constant (from_addr, len));
  1431.       data.autinc_from = 1;
  1432.       data.explicit_inc_from = -1;
  1433.     }
  1434. #endif
  1435. #ifdef HAVE_POST_INCREMENT
  1436.       if (! data.autinc_from)
  1437.     {
  1438.       data.from_addr = copy_addr_to_reg (from_addr);
  1439.       data.autinc_from = 1;
  1440.       data.explicit_inc_from = 1;
  1441.     }
  1442. #endif
  1443.       if (!data.autinc_from && CONSTANT_P (from_addr))
  1444.     data.from_addr = copy_addr_to_reg (from_addr);
  1445. #ifdef HAVE_PRE_DECREMENT
  1446.       if (data.reverse && ! data.autinc_to)
  1447.     {
  1448.       data.to_addr = copy_addr_to_reg (plus_constant (to_addr, len));
  1449.       data.autinc_to = 1;
  1450.       data.explicit_inc_to = -1;
  1451.     }
  1452. #endif
  1453. #ifdef HAVE_POST_INCREMENT
  1454.       if (! data.reverse && ! data.autinc_to)
  1455.     {
  1456.       data.to_addr = copy_addr_to_reg (to_addr);
  1457.       data.autinc_to = 1;
  1458.       data.explicit_inc_to = 1;
  1459.     }
  1460. #endif
  1461.       if (!data.autinc_to && CONSTANT_P (to_addr))
  1462.     data.to_addr = copy_addr_to_reg (to_addr);
  1463.     }
  1464.  
  1465.   if (! SLOW_UNALIGNED_ACCESS
  1466.       || align > MOVE_MAX || align >= BIGGEST_ALIGNMENT / BITS_PER_UNIT)
  1467.     align = MOVE_MAX;
  1468.  
  1469.   /* First move what we can in the largest integer mode, then go to
  1470.      successively smaller modes.  */
  1471.  
  1472.   while (max_size > 1)
  1473.     {
  1474.       enum machine_mode mode = VOIDmode, tmode;
  1475.       enum insn_code icode;
  1476.  
  1477.       for (tmode = GET_CLASS_NARROWEST_MODE (MODE_INT);
  1478.        tmode != VOIDmode; tmode = GET_MODE_WIDER_MODE (tmode))
  1479.     if (GET_MODE_SIZE (tmode) < max_size)
  1480.       mode = tmode;
  1481.  
  1482.       if (mode == VOIDmode)
  1483.     break;
  1484.  
  1485.       icode = mov_optab->handlers[(int) mode].insn_code;
  1486.       if (icode != CODE_FOR_nothing
  1487.       && align >= MIN (BIGGEST_ALIGNMENT / BITS_PER_UNIT,
  1488.                GET_MODE_SIZE (mode)))
  1489.     move_by_pieces_1 (GEN_FCN (icode), mode, &data);
  1490.  
  1491.       max_size = GET_MODE_SIZE (mode);
  1492.     }
  1493.  
  1494.   /* The code above should have handled everything.  */
  1495.   if (data.len != 0)
  1496.     abort ();
  1497. }
  1498.  
  1499. /* Return number of insns required to move L bytes by pieces.
  1500.    ALIGN (in bytes) is maximum alignment we can assume.  */
  1501.  
  1502. static int
  1503. move_by_pieces_ninsns (l, align)
  1504.      unsigned int l;
  1505.      int align;
  1506. {
  1507.   register int n_insns = 0;
  1508.   int max_size = MOVE_MAX + 1;
  1509.  
  1510.   if (! SLOW_UNALIGNED_ACCESS
  1511.       || align > MOVE_MAX || align >= BIGGEST_ALIGNMENT / BITS_PER_UNIT)
  1512.     align = MOVE_MAX;
  1513.  
  1514.   while (max_size > 1)
  1515.     {
  1516.       enum machine_mode mode = VOIDmode, tmode;
  1517.       enum insn_code icode;
  1518.  
  1519.       for (tmode = GET_CLASS_NARROWEST_MODE (MODE_INT);
  1520.        tmode != VOIDmode; tmode = GET_MODE_WIDER_MODE (tmode))
  1521.     if (GET_MODE_SIZE (tmode) < max_size)
  1522.       mode = tmode;
  1523.  
  1524.       if (mode == VOIDmode)
  1525.     break;
  1526.  
  1527.       icode = mov_optab->handlers[(int) mode].insn_code;
  1528.       if (icode != CODE_FOR_nothing
  1529.       && align >= MIN (BIGGEST_ALIGNMENT / BITS_PER_UNIT,
  1530.                GET_MODE_SIZE (mode)))
  1531.     n_insns += l / GET_MODE_SIZE (mode), l %= GET_MODE_SIZE (mode);
  1532.  
  1533.       max_size = GET_MODE_SIZE (mode);
  1534.     }
  1535.  
  1536.   return n_insns;
  1537. }
  1538.  
  1539. /* Subroutine of move_by_pieces.  Move as many bytes as appropriate
  1540.    with move instructions for mode MODE.  GENFUN is the gen_... function
  1541.    to make a move insn for that mode.  DATA has all the other info.  */
  1542.  
  1543. static void
  1544. move_by_pieces_1 (genfun, mode, data)
  1545.      rtx (*genfun) ();
  1546.      enum machine_mode mode;
  1547.      struct move_by_pieces *data;
  1548. {
  1549.   register int size = GET_MODE_SIZE (mode);
  1550.   register rtx to1, from1;
  1551.  
  1552.   while (data->len >= size)
  1553.     {
  1554.       if (data->reverse) data->offset -= size;
  1555.  
  1556.       to1 = (data->autinc_to
  1557.          ? gen_rtx (MEM, mode, data->to_addr)
  1558.          : change_address (data->to, mode,
  1559.                    plus_constant (data->to_addr, data->offset)));
  1560.       MEM_IN_STRUCT_P (to1) = data->to_struct;
  1561.       from1 =
  1562.     (data->autinc_from
  1563.      ? gen_rtx (MEM, mode, data->from_addr)
  1564.      : change_address (data->from, mode,
  1565.                plus_constant (data->from_addr, data->offset)));
  1566.       MEM_IN_STRUCT_P (from1) = data->from_struct;
  1567.  
  1568. #ifdef HAVE_PRE_DECREMENT
  1569.       if (data->explicit_inc_to < 0)
  1570.     emit_insn (gen_add2_insn (data->to_addr, GEN_INT (-size)));
  1571.       if (data->explicit_inc_from < 0)
  1572.     emit_insn (gen_add2_insn (data->from_addr, GEN_INT (-size)));
  1573. #endif
  1574.  
  1575.       emit_insn ((*genfun) (to1, from1));
  1576. #ifdef HAVE_POST_INCREMENT
  1577.       if (data->explicit_inc_to > 0)
  1578.     emit_insn (gen_add2_insn (data->to_addr, GEN_INT (size)));
  1579.       if (data->explicit_inc_from > 0)
  1580.     emit_insn (gen_add2_insn (data->from_addr, GEN_INT (size)));
  1581. #endif
  1582.  
  1583.       if (! data->reverse) data->offset += size;
  1584.  
  1585.       data->len -= size;
  1586.     }
  1587. }
  1588.  
  1589. /* Emit code to move a block Y to a block X.
  1590.    This may be done with string-move instructions,
  1591.    with multiple scalar move instructions, or with a library call.
  1592.  
  1593.    Both X and Y must be MEM rtx's (perhaps inside VOLATILE)
  1594.    with mode BLKmode.
  1595.    SIZE is an rtx that says how long they are.
  1596.    ALIGN is the maximum alignment we can assume they have,
  1597.    measured in bytes.  */
  1598.  
  1599. void
  1600. emit_block_move (x, y, size, align)
  1601.      rtx x, y;
  1602.      rtx size;
  1603.      int align;
  1604. {
  1605.   if (GET_MODE (x) != BLKmode)
  1606.     abort ();
  1607.  
  1608.   if (GET_MODE (y) != BLKmode)
  1609.     abort ();
  1610.  
  1611.   x = protect_from_queue (x, 1);
  1612.   y = protect_from_queue (y, 0);
  1613.   size = protect_from_queue (size, 0);
  1614.  
  1615.   if (GET_CODE (x) != MEM)
  1616.     abort ();
  1617.   if (GET_CODE (y) != MEM)
  1618.     abort ();
  1619.   if (size == 0)
  1620.     abort ();
  1621.  
  1622.   if (GET_CODE (size) == CONST_INT
  1623.       && (move_by_pieces_ninsns (INTVAL (size), align) < MOVE_RATIO))
  1624.     move_by_pieces (x, y, INTVAL (size), align);
  1625.   else
  1626.     {
  1627.       /* Try the most limited insn first, because there's no point
  1628.      including more than one in the machine description unless
  1629.      the more limited one has some advantage.  */
  1630.  
  1631.       rtx opalign = GEN_INT (align);
  1632.       enum machine_mode mode;
  1633.  
  1634.       for (mode = GET_CLASS_NARROWEST_MODE (MODE_INT); mode != VOIDmode;
  1635.        mode = GET_MODE_WIDER_MODE (mode))
  1636.     {
  1637.       enum insn_code code = movstr_optab[(int) mode];
  1638.  
  1639.       if (code != CODE_FOR_nothing
  1640.           /* We don't need MODE to be narrower than BITS_PER_HOST_WIDE_INT
  1641.          here because if SIZE is less than the mode mask, as it is
  1642.          returned by the macro, it will definitely be less than the
  1643.          actual mode mask.  */
  1644.           && ((GET_CODE (size) == CONST_INT
  1645.            && ((unsigned HOST_WIDE_INT) INTVAL (size)
  1646.                <= GET_MODE_MASK (mode)))
  1647.           || GET_MODE_BITSIZE (mode) >= BITS_PER_WORD)
  1648.           && (insn_operand_predicate[(int) code][0] == 0
  1649.           || (*insn_operand_predicate[(int) code][0]) (x, BLKmode))
  1650.           && (insn_operand_predicate[(int) code][1] == 0
  1651.           || (*insn_operand_predicate[(int) code][1]) (y, BLKmode))
  1652.           && (insn_operand_predicate[(int) code][3] == 0
  1653.           || (*insn_operand_predicate[(int) code][3]) (opalign,
  1654.                                    VOIDmode)))
  1655.         {
  1656.           rtx op2;
  1657.           rtx last = get_last_insn ();
  1658.           rtx pat;
  1659.  
  1660.           op2 = convert_to_mode (mode, size, 1);
  1661.           if (insn_operand_predicate[(int) code][2] != 0
  1662.           && ! (*insn_operand_predicate[(int) code][2]) (op2, mode))
  1663.         op2 = copy_to_mode_reg (mode, op2);
  1664.  
  1665.           pat = GEN_FCN ((int) code) (x, y, op2, opalign);
  1666.           if (pat)
  1667.         {
  1668.           emit_insn (pat);
  1669.           return;
  1670.         }
  1671.           else
  1672.         delete_insns_since (last);
  1673.         }
  1674.     }
  1675.  
  1676. #ifdef TARGET_MEM_FUNCTIONS
  1677.       emit_library_call (memcpy_libfunc, 0,
  1678.              VOIDmode, 3, XEXP (x, 0), Pmode,
  1679.              XEXP (y, 0), Pmode,
  1680.              convert_to_mode (TYPE_MODE (sizetype), size,
  1681.                       TREE_UNSIGNED (sizetype)),
  1682.              TYPE_MODE (sizetype));
  1683. #else
  1684.       emit_library_call (bcopy_libfunc, 0,
  1685.              VOIDmode, 3, XEXP (y, 0), Pmode,
  1686.              XEXP (x, 0), Pmode,
  1687.              convert_to_mode (TYPE_MODE (sizetype), size,
  1688.                       TREE_UNSIGNED (sizetype)),
  1689.              TYPE_MODE (sizetype));
  1690. #endif
  1691.     }
  1692. }
  1693.  
  1694. /* Copy all or part of a value X into registers starting at REGNO.
  1695.    The number of registers to be filled is NREGS.  */
  1696.  
  1697. void
  1698. move_block_to_reg (regno, x, nregs, mode)
  1699.      int regno;
  1700.      rtx x;
  1701.      int nregs;
  1702.      enum machine_mode mode;
  1703. {
  1704.   int i;
  1705.   rtx pat, last;
  1706.  
  1707.   if (nregs == 0)
  1708.     return;
  1709.  
  1710.   if (CONSTANT_P (x) && ! LEGITIMATE_CONSTANT_P (x))
  1711.     x = validize_mem (force_const_mem (mode, x));
  1712.  
  1713.   /* See if the machine can do this with a load multiple insn.  */
  1714. #ifdef HAVE_load_multiple
  1715.   if (HAVE_load_multiple)
  1716.     {
  1717.       last = get_last_insn ();
  1718.       pat = gen_load_multiple (gen_rtx (REG, word_mode, regno), x,
  1719.                    GEN_INT (nregs));
  1720.       if (pat)
  1721.     {
  1722.       emit_insn (pat);
  1723.       return;
  1724.     }
  1725.       else
  1726.     delete_insns_since (last);
  1727.     }
  1728. #endif
  1729.  
  1730.   for (i = 0; i < nregs; i++)
  1731.     emit_move_insn (gen_rtx (REG, word_mode, regno + i),
  1732.             operand_subword_force (x, i, mode));
  1733. }
  1734.  
  1735. /* Copy all or part of a BLKmode value X out of registers starting at REGNO.
  1736.    The number of registers to be filled is NREGS.  SIZE indicates the number
  1737.    of bytes in the object X.  */
  1738.  
  1739.  
  1740. void
  1741. move_block_from_reg (regno, x, nregs, size)
  1742.      int regno;
  1743.      rtx x;
  1744.      int nregs;
  1745.      int size;
  1746. {
  1747.   int i;
  1748.   rtx pat, last;
  1749.  
  1750.   /* Blocks smaller than a word on a BYTES_BIG_ENDIAN machine must be aligned
  1751.      to the left before storing to memory.  */
  1752.   if (size < UNITS_PER_WORD && BYTES_BIG_ENDIAN)
  1753.     {
  1754.       rtx tem = operand_subword (x, 0, 1, BLKmode);
  1755.       rtx shift;
  1756.  
  1757.       if (tem == 0)
  1758.     abort ();
  1759.  
  1760.       shift = expand_shift (LSHIFT_EXPR, word_mode,
  1761.                 gen_rtx (REG, word_mode, regno),
  1762.                 build_int_2 ((UNITS_PER_WORD - size)
  1763.                      * BITS_PER_UNIT, 0), NULL_RTX, 0);
  1764.       emit_move_insn (tem, shift);
  1765.       return;
  1766.     }
  1767.  
  1768.   /* See if the machine can do this with a store multiple insn.  */
  1769. #ifdef HAVE_store_multiple
  1770.   if (HAVE_store_multiple)
  1771.     {
  1772.       last = get_last_insn ();
  1773.       pat = gen_store_multiple (x, gen_rtx (REG, word_mode, regno),
  1774.                 GEN_INT (nregs));
  1775.       if (pat)
  1776.     {
  1777.       emit_insn (pat);
  1778.       return;
  1779.     }
  1780.       else
  1781.     delete_insns_since (last);
  1782.     }
  1783. #endif
  1784.  
  1785.   for (i = 0; i < nregs; i++)
  1786.     {
  1787.       rtx tem = operand_subword (x, i, 1, BLKmode);
  1788.  
  1789.       if (tem == 0)
  1790.     abort ();
  1791.  
  1792.       emit_move_insn (tem, gen_rtx (REG, word_mode, regno + i));
  1793.     }
  1794. }
  1795.  
  1796. /* Add a USE expression for REG to the (possibly empty) list pointed
  1797.    to by CALL_FUSAGE.  REG must denote a hard register.  */
  1798.  
  1799. void
  1800. use_reg (call_fusage, reg)
  1801.      rtx *call_fusage, reg;
  1802. {
  1803.   if (GET_CODE (reg) != REG
  1804.       || REGNO (reg) >= FIRST_PSEUDO_REGISTER)
  1805.     abort();
  1806.  
  1807.   *call_fusage
  1808.     = gen_rtx (EXPR_LIST, VOIDmode,
  1809.            gen_rtx (USE, VOIDmode, reg), *call_fusage);
  1810. }
  1811.  
  1812. /* Add USE expressions to *CALL_FUSAGE for each of NREGS consecutive regs,
  1813.    starting at REGNO.  All of these registers must be hard registers.  */
  1814.  
  1815. void
  1816. use_regs (call_fusage, regno, nregs)
  1817.      rtx *call_fusage;
  1818.      int regno;
  1819.      int nregs;
  1820. {
  1821.   int i;
  1822.  
  1823.   if (regno + nregs > FIRST_PSEUDO_REGISTER)
  1824.     abort ();
  1825.  
  1826.   for (i = 0; i < nregs; i++)
  1827.     use_reg (call_fusage, gen_rtx (REG, reg_raw_mode[regno + i], regno + i));
  1828. }
  1829.  
  1830. /* Write zeros through the storage of OBJECT.
  1831.    If OBJECT has BLKmode, SIZE is its length in bytes.  */
  1832.  
  1833. void
  1834. clear_storage (object, size)
  1835.      rtx object;
  1836.      int size;
  1837. {
  1838.   if (GET_MODE (object) == BLKmode)
  1839.     {
  1840. #ifdef TARGET_MEM_FUNCTIONS
  1841.       emit_library_call (memset_libfunc, 0,
  1842.              VOIDmode, 3,
  1843.              XEXP (object, 0), Pmode, const0_rtx, ptr_mode,
  1844.              GEN_INT (size), ptr_mode);
  1845. #else
  1846.       emit_library_call (bzero_libfunc, 0,
  1847.              VOIDmode, 2,
  1848.              XEXP (object, 0), Pmode,
  1849.              GEN_INT (size), ptr_mode);
  1850. #endif
  1851.     }
  1852.   else
  1853.     emit_move_insn (object, const0_rtx);
  1854. }
  1855.  
  1856. /* Generate code to copy Y into X.
  1857.    Both Y and X must have the same mode, except that
  1858.    Y can be a constant with VOIDmode.
  1859.    This mode cannot be BLKmode; use emit_block_move for that.
  1860.  
  1861.    Return the last instruction emitted.  */
  1862.  
  1863. rtx
  1864. emit_move_insn (x, y)
  1865.      rtx x, y;
  1866. {
  1867.   enum machine_mode mode = GET_MODE (x);
  1868.  
  1869.   x = protect_from_queue (x, 1);
  1870.   y = protect_from_queue (y, 0);
  1871.  
  1872.   if (mode == BLKmode || (GET_MODE (y) != mode && GET_MODE (y) != VOIDmode))
  1873.     abort ();
  1874.  
  1875.   if (CONSTANT_P (y) && ! LEGITIMATE_CONSTANT_P (y))
  1876.     y = force_const_mem (mode, y);
  1877.  
  1878.   /* If X or Y are memory references, verify that their addresses are valid
  1879.      for the machine.  */
  1880.   if (GET_CODE (x) == MEM
  1881.       && ((! memory_address_p (GET_MODE (x), XEXP (x, 0))
  1882.        && ! push_operand (x, GET_MODE (x)))
  1883.       || (flag_force_addr
  1884.           && CONSTANT_ADDRESS_P (XEXP (x, 0)))))
  1885.     x = change_address (x, VOIDmode, XEXP (x, 0));
  1886.  
  1887.   if (GET_CODE (y) == MEM
  1888.       && (! memory_address_p (GET_MODE (y), XEXP (y, 0))
  1889.       || (flag_force_addr
  1890.           && CONSTANT_ADDRESS_P (XEXP (y, 0)))))
  1891.     y = change_address (y, VOIDmode, XEXP (y, 0));
  1892.  
  1893.   if (mode == BLKmode)
  1894.     abort ();
  1895.  
  1896.   return emit_move_insn_1 (x, y);
  1897. }
  1898.  
  1899. /* Low level part of emit_move_insn.
  1900.    Called just like emit_move_insn, but assumes X and Y
  1901.    are basically valid.  */
  1902.  
  1903. rtx
  1904. emit_move_insn_1 (x, y)
  1905.      rtx x, y;
  1906. {
  1907.   enum machine_mode mode = GET_MODE (x);
  1908.   enum machine_mode submode;
  1909.   enum mode_class class = GET_MODE_CLASS (mode);
  1910.   int i;
  1911.  
  1912.   if (mov_optab->handlers[(int) mode].insn_code != CODE_FOR_nothing)
  1913.     return
  1914.       emit_insn (GEN_FCN (mov_optab->handlers[(int) mode].insn_code) (x, y));
  1915.  
  1916.   /* Expand complex moves by moving real part and imag part, if possible.  */
  1917.   else if ((class == MODE_COMPLEX_FLOAT || class == MODE_COMPLEX_INT)
  1918.        && BLKmode != (submode = mode_for_size ((GET_MODE_UNIT_SIZE (mode)
  1919.                             * BITS_PER_UNIT),
  1920.                            (class == MODE_COMPLEX_INT
  1921.                             ? MODE_INT : MODE_FLOAT),
  1922.                            0))
  1923.        && (mov_optab->handlers[(int) submode].insn_code
  1924.            != CODE_FOR_nothing))
  1925.     {
  1926.       /* Don't split destination if it is a stack push.  */
  1927.       int stack = push_operand (x, GET_MODE (x));
  1928.       rtx insns;
  1929.  
  1930.       /* If this is a stack, push the highpart first, so it
  1931.      will be in the argument order.
  1932.  
  1933.      In that case, change_address is used only to convert
  1934.      the mode, not to change the address.  */
  1935.       if (stack)
  1936.     {
  1937.       /* Note that the real part always precedes the imag part in memory
  1938.          regardless of machine's endianness.  */
  1939. #ifdef STACK_GROWS_DOWNWARD
  1940.       emit_insn (GEN_FCN (mov_optab->handlers[(int) submode].insn_code)
  1941.              (gen_rtx (MEM, submode, (XEXP (x, 0))),
  1942.               gen_imagpart (submode, y)));
  1943.       emit_insn (GEN_FCN (mov_optab->handlers[(int) submode].insn_code)
  1944.              (gen_rtx (MEM, submode, (XEXP (x, 0))),
  1945.               gen_realpart (submode, y)));
  1946. #else
  1947.       emit_insn (GEN_FCN (mov_optab->handlers[(int) submode].insn_code)
  1948.              (gen_rtx (MEM, submode, (XEXP (x, 0))),
  1949.               gen_realpart (submode, y)));
  1950.       emit_insn (GEN_FCN (mov_optab->handlers[(int) submode].insn_code)
  1951.              (gen_rtx (MEM, submode, (XEXP (x, 0))),
  1952.               gen_imagpart (submode, y)));
  1953. #endif
  1954.     }
  1955.       else
  1956.     {
  1957.       emit_insn (GEN_FCN (mov_optab->handlers[(int) submode].insn_code)
  1958.              (gen_realpart (submode, x), gen_realpart (submode, y)));
  1959.       emit_insn (GEN_FCN (mov_optab->handlers[(int) submode].insn_code)
  1960.              (gen_imagpart (submode, x), gen_imagpart (submode, y)));
  1961.     }
  1962.  
  1963.       return get_last_insn ();
  1964.     }
  1965.  
  1966.   /* This will handle any multi-word mode that lacks a move_insn pattern.
  1967.      However, you will get better code if you define such patterns,
  1968.      even if they must turn into multiple assembler instructions.  */
  1969.   else if (GET_MODE_SIZE (mode) > UNITS_PER_WORD)
  1970.     {
  1971.       rtx last_insn = 0;
  1972.       rtx insns;
  1973.       
  1974. #ifdef PUSH_ROUNDING
  1975.  
  1976.       /* If X is a push on the stack, do the push now and replace
  1977.      X with a reference to the stack pointer.  */
  1978.       if (push_operand (x, GET_MODE (x)))
  1979.     {
  1980.       anti_adjust_stack (GEN_INT (GET_MODE_SIZE (GET_MODE (x))));
  1981.       x = change_address (x, VOIDmode, stack_pointer_rtx);
  1982.     }
  1983. #endif
  1984.                  
  1985.       for (i = 0;
  1986.        i < (GET_MODE_SIZE (mode)  + (UNITS_PER_WORD - 1)) / UNITS_PER_WORD;
  1987.        i++)
  1988.     {
  1989.       rtx xpart = operand_subword (x, i, 1, mode);
  1990.       rtx ypart = operand_subword (y, i, 1, mode);
  1991.  
  1992.       /* If we can't get a part of Y, put Y into memory if it is a
  1993.          constant.  Otherwise, force it into a register.  If we still
  1994.          can't get a part of Y, abort.  */
  1995.       if (ypart == 0 && CONSTANT_P (y))
  1996.         {
  1997.           y = force_const_mem (mode, y);
  1998.           ypart = operand_subword (y, i, 1, mode);
  1999.         }
  2000.       else if (ypart == 0)
  2001.         ypart = operand_subword_force (y, i, mode);
  2002.  
  2003.       if (xpart == 0 || ypart == 0)
  2004.         abort ();
  2005.  
  2006.       last_insn = emit_move_insn (xpart, ypart);
  2007.     }
  2008.  
  2009.       return last_insn;
  2010.     }
  2011.   else
  2012.     abort ();
  2013. }
  2014.  
  2015. /* Pushing data onto the stack.  */
  2016.  
  2017. /* Push a block of length SIZE (perhaps variable)
  2018.    and return an rtx to address the beginning of the block.
  2019.    Note that it is not possible for the value returned to be a QUEUED.
  2020.    The value may be virtual_outgoing_args_rtx.
  2021.  
  2022.    EXTRA is the number of bytes of padding to push in addition to SIZE.
  2023.    BELOW nonzero means this padding comes at low addresses;
  2024.    otherwise, the padding comes at high addresses.  */
  2025.  
  2026. rtx
  2027. push_block (size, extra, below)
  2028.      rtx size;
  2029.      int extra, below;
  2030. {
  2031.   register rtx temp;
  2032.  
  2033.   size = convert_modes (Pmode, ptr_mode, size, 1);
  2034.   if (CONSTANT_P (size))
  2035.     anti_adjust_stack (plus_constant (size, extra));
  2036.   else if (GET_CODE (size) == REG && extra == 0)
  2037.     anti_adjust_stack (size);
  2038.   else
  2039.     {
  2040.       rtx temp = copy_to_mode_reg (Pmode, size);
  2041.       if (extra != 0)
  2042.     temp = expand_binop (Pmode, add_optab, temp, GEN_INT (extra),
  2043.                  temp, 0, OPTAB_LIB_WIDEN);
  2044.       anti_adjust_stack (temp);
  2045.     }
  2046.  
  2047. #ifdef STACK_GROWS_DOWNWARD
  2048.   temp = virtual_outgoing_args_rtx;
  2049.   if (extra != 0 && below)
  2050.     temp = plus_constant (temp, extra);
  2051. #else
  2052.   if (GET_CODE (size) == CONST_INT)
  2053.     temp = plus_constant (virtual_outgoing_args_rtx,
  2054.               - INTVAL (size) - (below ? 0 : extra));
  2055.   else if (extra != 0 && !below)
  2056.     temp = gen_rtx (PLUS, Pmode, virtual_outgoing_args_rtx,
  2057.             negate_rtx (Pmode, plus_constant (size, extra)));
  2058.   else
  2059.     temp = gen_rtx (PLUS, Pmode, virtual_outgoing_args_rtx,
  2060.             negate_rtx (Pmode, size));
  2061. #endif
  2062.  
  2063.   return memory_address (GET_CLASS_NARROWEST_MODE (MODE_INT), temp);
  2064. }
  2065.  
  2066. rtx
  2067. gen_push_operand ()
  2068. {
  2069.   return gen_rtx (STACK_PUSH_CODE, Pmode, stack_pointer_rtx);
  2070. }
  2071.  
  2072. /* Generate code to push X onto the stack, assuming it has mode MODE and
  2073.    type TYPE.
  2074.    MODE is redundant except when X is a CONST_INT (since they don't
  2075.    carry mode info).
  2076.    SIZE is an rtx for the size of data to be copied (in bytes),
  2077.    needed only if X is BLKmode.
  2078.  
  2079.    ALIGN (in bytes) is maximum alignment we can assume.
  2080.  
  2081.    If PARTIAL and REG are both nonzero, then copy that many of the first
  2082.    words of X into registers starting with REG, and push the rest of X.
  2083.    The amount of space pushed is decreased by PARTIAL words,
  2084.    rounded *down* to a multiple of PARM_BOUNDARY.
  2085.    REG must be a hard register in this case.
  2086.    If REG is zero but PARTIAL is not, take any all others actions for an
  2087.    argument partially in registers, but do not actually load any
  2088.    registers.
  2089.  
  2090.    EXTRA is the amount in bytes of extra space to leave next to this arg.
  2091.    This is ignored if an argument block has already been allocated.
  2092.  
  2093.    On a machine that lacks real push insns, ARGS_ADDR is the address of
  2094.    the bottom of the argument block for this call.  We use indexing off there
  2095.    to store the arg.  On machines with push insns, ARGS_ADDR is 0 when a
  2096.    argument block has not been preallocated.
  2097.  
  2098.    ARGS_SO_FAR is the size of args previously pushed for this call.  */
  2099.  
  2100. void
  2101. emit_push_insn (x, mode, type, size, align, partial, reg, extra,
  2102.         args_addr, args_so_far)
  2103.      register rtx x;
  2104.      enum machine_mode mode;
  2105.      tree type;
  2106.      rtx size;
  2107.      int align;
  2108.      int partial;
  2109.      rtx reg;
  2110.      int extra;
  2111.      rtx args_addr;
  2112.      rtx args_so_far;
  2113. {
  2114.   rtx xinner;
  2115.   enum direction stack_direction
  2116. #ifdef STACK_GROWS_DOWNWARD
  2117.     = downward;
  2118. #else
  2119.     = upward;
  2120. #endif
  2121.  
  2122.   /* Decide where to pad the argument: `downward' for below,
  2123.      `upward' for above, or `none' for don't pad it.
  2124.      Default is below for small data on big-endian machines; else above.  */
  2125.   enum direction where_pad = FUNCTION_ARG_PADDING (mode, type);
  2126.  
  2127.   /* Invert direction if stack is post-update.  */
  2128.   if (STACK_PUSH_CODE == POST_INC || STACK_PUSH_CODE == POST_DEC)
  2129.     if (where_pad != none)
  2130.       where_pad = (where_pad == downward ? upward : downward);
  2131.  
  2132.   xinner = x = protect_from_queue (x, 0);
  2133.  
  2134.   if (mode == BLKmode)
  2135.     {
  2136.       /* Copy a block into the stack, entirely or partially.  */
  2137.  
  2138.       register rtx temp;
  2139.       int used = partial * UNITS_PER_WORD;
  2140.       int offset = used % (PARM_BOUNDARY / BITS_PER_UNIT);
  2141.       int skip;
  2142.       
  2143.       if (size == 0)
  2144.     abort ();
  2145.  
  2146.       used -= offset;
  2147.  
  2148.       /* USED is now the # of bytes we need not copy to the stack
  2149.      because registers will take care of them.  */
  2150.  
  2151.       if (partial != 0)
  2152.     xinner = change_address (xinner, BLKmode,
  2153.                  plus_constant (XEXP (xinner, 0), used));
  2154.  
  2155.       /* If the partial register-part of the arg counts in its stack size,
  2156.      skip the part of stack space corresponding to the registers.
  2157.      Otherwise, start copying to the beginning of the stack space,
  2158.      by setting SKIP to 0.  */
  2159. #ifndef REG_PARM_STACK_SPACE
  2160.       skip = 0;
  2161. #else
  2162.       skip = used;
  2163. #endif
  2164.  
  2165. #ifdef PUSH_ROUNDING
  2166.       /* Do it with several push insns if that doesn't take lots of insns
  2167.      and if there is no difficulty with push insns that skip bytes
  2168.      on the stack for alignment purposes.  */
  2169.       if (args_addr == 0
  2170.       && GET_CODE (size) == CONST_INT
  2171.       && skip == 0
  2172.       && (move_by_pieces_ninsns ((unsigned) INTVAL (size) - used, align)
  2173.           < MOVE_RATIO)
  2174.       /* Here we avoid the case of a structure whose weak alignment
  2175.          forces many pushes of a small amount of data,
  2176.          and such small pushes do rounding that causes trouble.  */
  2177.       && ((! SLOW_UNALIGNED_ACCESS)
  2178.           || align >= BIGGEST_ALIGNMENT / BITS_PER_UNIT
  2179.           || PUSH_ROUNDING (align) == align)
  2180.       && PUSH_ROUNDING (INTVAL (size)) == INTVAL (size))
  2181.     {
  2182.       /* Push padding now if padding above and stack grows down,
  2183.          or if padding below and stack grows up.
  2184.          But if space already allocated, this has already been done.  */
  2185.       if (extra && args_addr == 0
  2186.           && where_pad != none && where_pad != stack_direction)
  2187.         anti_adjust_stack (GEN_INT (extra));
  2188.  
  2189.       move_by_pieces (gen_rtx (MEM, BLKmode, gen_push_operand ()), xinner,
  2190.               INTVAL (size) - used, align);
  2191.     }
  2192.       else
  2193. #endif /* PUSH_ROUNDING */
  2194.     {
  2195.       /* Otherwise make space on the stack and copy the data
  2196.          to the address of that space.  */
  2197.  
  2198.       /* Deduct words put into registers from the size we must copy.  */
  2199.       if (partial != 0)
  2200.         {
  2201.           if (GET_CODE (size) == CONST_INT)
  2202.         size = GEN_INT (INTVAL (size) - used);
  2203.           else
  2204.         size = expand_binop (GET_MODE (size), sub_optab, size,
  2205.                      GEN_INT (used), NULL_RTX, 0,
  2206.                      OPTAB_LIB_WIDEN);
  2207.         }
  2208.  
  2209.       /* Get the address of the stack space.
  2210.          In this case, we do not deal with EXTRA separately.
  2211.          A single stack adjust will do.  */
  2212.       if (! args_addr)
  2213.         {
  2214.           temp = push_block (size, extra, where_pad == downward);
  2215.           extra = 0;
  2216.         }
  2217.       else if (GET_CODE (args_so_far) == CONST_INT)
  2218.         temp = memory_address (BLKmode,
  2219.                    plus_constant (args_addr,
  2220.                           skip + INTVAL (args_so_far)));
  2221.       else
  2222.         temp = memory_address (BLKmode,
  2223.                    plus_constant (gen_rtx (PLUS, Pmode,
  2224.                                args_addr, args_so_far),
  2225.                           skip));
  2226.  
  2227.       /* TEMP is the address of the block.  Copy the data there.  */
  2228.       if (GET_CODE (size) == CONST_INT
  2229.           && (move_by_pieces_ninsns ((unsigned) INTVAL (size), align)
  2230.           < MOVE_RATIO))
  2231.         {
  2232.           move_by_pieces (gen_rtx (MEM, BLKmode, temp), xinner,
  2233.                   INTVAL (size), align);
  2234.           goto ret;
  2235.         }
  2236.       /* Try the most limited insn first, because there's no point
  2237.          including more than one in the machine description unless
  2238.          the more limited one has some advantage.  */
  2239. #ifdef HAVE_movstrqi
  2240.       if (HAVE_movstrqi
  2241.           && GET_CODE (size) == CONST_INT
  2242.           && ((unsigned) INTVAL (size)
  2243.           < (1 << (GET_MODE_BITSIZE (QImode) - 1))))
  2244.         {
  2245.           rtx pat = gen_movstrqi (gen_rtx (MEM, BLKmode, temp),
  2246.                       xinner, size, GEN_INT (align));
  2247.           if (pat != 0)
  2248.         {
  2249.           emit_insn (pat);
  2250.           goto ret;
  2251.         }
  2252.         }
  2253. #endif
  2254. #ifdef HAVE_movstrhi
  2255.       if (HAVE_movstrhi
  2256.           && GET_CODE (size) == CONST_INT
  2257.           && ((unsigned) INTVAL (size)
  2258.           < (1 << (GET_MODE_BITSIZE (HImode) - 1))))
  2259.         {
  2260.           rtx pat = gen_movstrhi (gen_rtx (MEM, BLKmode, temp),
  2261.                       xinner, size, GEN_INT (align));
  2262.           if (pat != 0)
  2263.         {
  2264.           emit_insn (pat);
  2265.           goto ret;
  2266.         }
  2267.         }
  2268. #endif
  2269. #ifdef HAVE_movstrsi
  2270.       if (HAVE_movstrsi)
  2271.         {
  2272.           rtx pat = gen_movstrsi (gen_rtx (MEM, BLKmode, temp),
  2273.                       xinner, size, GEN_INT (align));
  2274.           if (pat != 0)
  2275.         {
  2276.           emit_insn (pat);
  2277.           goto ret;
  2278.         }
  2279.         }
  2280. #endif
  2281. #ifdef HAVE_movstrdi
  2282.       if (HAVE_movstrdi)
  2283.         {
  2284.           rtx pat = gen_movstrdi (gen_rtx (MEM, BLKmode, temp),
  2285.                       xinner, size, GEN_INT (align));
  2286.           if (pat != 0)
  2287.         {
  2288.           emit_insn (pat);
  2289.           goto ret;
  2290.         }
  2291.         }
  2292. #endif
  2293.  
  2294. #ifndef ACCUMULATE_OUTGOING_ARGS
  2295.       /* If the source is referenced relative to the stack pointer,
  2296.          copy it to another register to stabilize it.  We do not need
  2297.          to do this if we know that we won't be changing sp.  */
  2298.  
  2299.       if (reg_mentioned_p (virtual_stack_dynamic_rtx, temp)
  2300.           || reg_mentioned_p (virtual_outgoing_args_rtx, temp))
  2301.         temp = copy_to_reg (temp);
  2302. #endif
  2303.  
  2304.       /* Make inhibit_defer_pop nonzero around the library call
  2305.          to force it to pop the bcopy-arguments right away.  */
  2306.       NO_DEFER_POP;
  2307. #ifdef TARGET_MEM_FUNCTIONS
  2308.       emit_library_call (memcpy_libfunc, 0,
  2309.                  VOIDmode, 3, temp, Pmode, XEXP (xinner, 0), Pmode,
  2310.                  convert_to_mode (TYPE_MODE (sizetype),
  2311.                           size, TREE_UNSIGNED (sizetype)),
  2312.                  TYPE_MODE (sizetype));
  2313. #else
  2314.       emit_library_call (bcopy_libfunc, 0,
  2315.                  VOIDmode, 3, XEXP (xinner, 0), Pmode, temp, Pmode,
  2316.                  convert_to_mode (TYPE_MODE (sizetype),
  2317.                           size, TREE_UNSIGNED (sizetype)),
  2318.                  TYPE_MODE (sizetype));
  2319. #endif
  2320.       OK_DEFER_POP;
  2321.     }
  2322.     }
  2323.   else if (partial > 0)
  2324.     {
  2325.       /* Scalar partly in registers.  */
  2326.  
  2327.       int size = GET_MODE_SIZE (mode) / UNITS_PER_WORD;
  2328.       int i;
  2329.       int not_stack;
  2330.       /* # words of start of argument
  2331.      that we must make space for but need not store.  */
  2332.       int offset = partial % (PARM_BOUNDARY / BITS_PER_WORD);
  2333.       int args_offset = INTVAL (args_so_far);
  2334.       int skip;
  2335.  
  2336.       /* Push padding now if padding above and stack grows down,
  2337.      or if padding below and stack grows up.
  2338.      But if space already allocated, this has already been done.  */
  2339.       if (extra && args_addr == 0
  2340.       && where_pad != none && where_pad != stack_direction)
  2341.     anti_adjust_stack (GEN_INT (extra));
  2342.  
  2343.       /* If we make space by pushing it, we might as well push
  2344.      the real data.  Otherwise, we can leave OFFSET nonzero
  2345.      and leave the space uninitialized.  */
  2346.       if (args_addr == 0)
  2347.     offset = 0;
  2348.  
  2349.       /* Now NOT_STACK gets the number of words that we don't need to
  2350.      allocate on the stack.  */
  2351.       not_stack = partial - offset;
  2352.  
  2353.       /* If the partial register-part of the arg counts in its stack size,
  2354.      skip the part of stack space corresponding to the registers.
  2355.      Otherwise, start copying to the beginning of the stack space,
  2356.      by setting SKIP to 0.  */
  2357. #ifndef REG_PARM_STACK_SPACE
  2358.       skip = 0;
  2359. #else
  2360.       skip = not_stack;
  2361. #endif
  2362.  
  2363.       if (CONSTANT_P (x) && ! LEGITIMATE_CONSTANT_P (x))
  2364.     x = validize_mem (force_const_mem (mode, x));
  2365.  
  2366.       /* If X is a hard register in a non-integer mode, copy it into a pseudo;
  2367.      SUBREGs of such registers are not allowed.  */
  2368.       if ((GET_CODE (x) == REG && REGNO (x) < FIRST_PSEUDO_REGISTER
  2369.        && GET_MODE_CLASS (GET_MODE (x)) != MODE_INT))
  2370.     x = copy_to_reg (x);
  2371.  
  2372.       /* Loop over all the words allocated on the stack for this arg.  */
  2373.       /* We can do it by words, because any scalar bigger than a word
  2374.      has a size a multiple of a word.  */
  2375. #ifndef PUSH_ARGS_REVERSED
  2376.       for (i = not_stack; i < size; i++)
  2377. #else
  2378.       for (i = size - 1; i >= not_stack; i--)
  2379. #endif
  2380.     if (i >= not_stack + offset)
  2381.       emit_push_insn (operand_subword_force (x, i, mode),
  2382.               word_mode, NULL_TREE, NULL_RTX, align, 0, NULL_RTX,
  2383.               0, args_addr,
  2384.               GEN_INT (args_offset + ((i - not_stack + skip)
  2385.                           * UNITS_PER_WORD)));
  2386.     }
  2387.   else
  2388.     {
  2389.       rtx addr;
  2390.  
  2391.       /* Push padding now if padding above and stack grows down,
  2392.      or if padding below and stack grows up.
  2393.      But if space already allocated, this has already been done.  */
  2394.       if (extra && args_addr == 0
  2395.       && where_pad != none && where_pad != stack_direction)
  2396.     anti_adjust_stack (GEN_INT (extra));
  2397.  
  2398. #ifdef PUSH_ROUNDING
  2399.       if (args_addr == 0)
  2400.     addr = gen_push_operand ();
  2401.       else
  2402. #endif
  2403.     if (GET_CODE (args_so_far) == CONST_INT)
  2404.       addr
  2405.         = memory_address (mode,
  2406.                   plus_constant (args_addr, INTVAL (args_so_far)));
  2407.       else
  2408.     addr = memory_address (mode, gen_rtx (PLUS, Pmode, args_addr,
  2409.                           args_so_far));
  2410.  
  2411.       emit_move_insn (gen_rtx (MEM, mode, addr), x);
  2412.     }
  2413.  
  2414.  ret:
  2415.   /* If part should go in registers, copy that part
  2416.      into the appropriate registers.  Do this now, at the end,
  2417.      since mem-to-mem copies above may do function calls.  */
  2418.   if (partial > 0 && reg != 0)
  2419.     move_block_to_reg (REGNO (reg), x, partial, mode);
  2420.  
  2421.   if (extra && args_addr == 0 && where_pad == stack_direction)
  2422.     anti_adjust_stack (GEN_INT (extra));
  2423. }
  2424.  
  2425. /* Expand an assignment that stores the value of FROM into TO.
  2426.    If WANT_VALUE is nonzero, return an rtx for the value of TO.
  2427.    (This may contain a QUEUED rtx;
  2428.    if the value is constant, this rtx is a constant.)
  2429.    Otherwise, the returned value is NULL_RTX.
  2430.  
  2431.    SUGGEST_REG is no longer actually used.
  2432.    It used to mean, copy the value through a register
  2433.    and return that register, if that is possible.
  2434.    We now use WANT_VALUE to decide whether to do this.  */
  2435.  
  2436. rtx
  2437. expand_assignment (to, from, want_value, suggest_reg)
  2438.      tree to, from;
  2439.      int want_value;
  2440.      int suggest_reg;
  2441. {
  2442.   register rtx to_rtx = 0;
  2443.   rtx result;
  2444.  
  2445.   /* Don't crash if the lhs of the assignment was erroneous.  */
  2446.  
  2447.   if (TREE_CODE (to) == ERROR_MARK)
  2448.     {
  2449.       result = expand_expr (from, NULL_RTX, VOIDmode, 0);
  2450.       return want_value ? result : NULL_RTX;
  2451.     }
  2452.  
  2453.   if (output_bytecode)
  2454.     {
  2455.       tree dest_innermost;
  2456.  
  2457.       bc_expand_expr (from);
  2458.       bc_emit_instruction (duplicate);
  2459.  
  2460.       dest_innermost = bc_expand_address (to);
  2461.  
  2462.       /* Can't deduce from TYPE that we're dealing with a bitfield, so
  2463.      take care of it here. */
  2464.  
  2465.       bc_store_memory (TREE_TYPE (to), dest_innermost);
  2466.       return NULL;
  2467.     }
  2468.  
  2469.   /* Assignment of a structure component needs special treatment
  2470.      if the structure component's rtx is not simply a MEM.
  2471.      Assignment of an array element at a constant index, and assignment of
  2472.      an array element in an unaligned packed structure field, has the same
  2473.      problem.  */
  2474.  
  2475.   if (TREE_CODE (to) == COMPONENT_REF
  2476.       || TREE_CODE (to) == BIT_FIELD_REF
  2477.       || (TREE_CODE (to) == ARRAY_REF
  2478.       && ((TREE_CODE (TREE_OPERAND (to, 1)) == INTEGER_CST
  2479.            && TREE_CODE (TYPE_SIZE (TREE_TYPE (to))) == INTEGER_CST)
  2480.           || (SLOW_UNALIGNED_ACCESS && get_inner_unaligned_p (to)))))
  2481.     {
  2482.       enum machine_mode mode1;
  2483.       int bitsize;
  2484.       int bitpos;
  2485.       tree offset;
  2486.       int unsignedp;
  2487.       int volatilep = 0;
  2488.       tree tem;
  2489.       int alignment;
  2490.  
  2491.       push_temp_slots ();
  2492.       tem = get_inner_reference (to, &bitsize, &bitpos, &offset,
  2493.                       &mode1, &unsignedp, &volatilep);
  2494.  
  2495.       /* If we are going to use store_bit_field and extract_bit_field,
  2496.      make sure to_rtx will be safe for multiple use.  */
  2497.  
  2498.       if (mode1 == VOIDmode && want_value)
  2499.     tem = stabilize_reference (tem);
  2500.  
  2501.       alignment = TYPE_ALIGN (TREE_TYPE (tem)) / BITS_PER_UNIT;
  2502.       to_rtx = expand_expr (tem, NULL_RTX, VOIDmode, 0);
  2503.       if (offset != 0)
  2504.     {
  2505.       rtx offset_rtx = expand_expr (offset, NULL_RTX, VOIDmode, 0);
  2506.  
  2507.       if (GET_CODE (to_rtx) != MEM)
  2508.         abort ();
  2509.       to_rtx = change_address (to_rtx, VOIDmode,
  2510.                    gen_rtx (PLUS, ptr_mode, XEXP (to_rtx, 0),
  2511.                         force_reg (ptr_mode, offset_rtx)));
  2512.       /* If we have a variable offset, the known alignment
  2513.          is only that of the innermost structure containing the field.
  2514.          (Actually, we could sometimes do better by using the
  2515.          align of an element of the innermost array, but no need.)  */
  2516.       if (TREE_CODE (to) == COMPONENT_REF
  2517.           || TREE_CODE (to) == BIT_FIELD_REF)
  2518.         alignment
  2519.           = TYPE_ALIGN (TREE_TYPE (TREE_OPERAND (to, 0))) / BITS_PER_UNIT;
  2520.     }
  2521.       if (volatilep)
  2522.     {
  2523.       if (GET_CODE (to_rtx) == MEM)
  2524.         {
  2525.           /* When the offset is zero, to_rtx is the address of the
  2526.          structure we are storing into, and hence may be shared.
  2527.          We must make a new MEM before setting the volatile bit.  */
  2528.           if (offset == 0)
  2529.         to_rtx = change_address (to_rtx, VOIDmode, XEXP (to_rtx, 0));
  2530.           MEM_VOLATILE_P (to_rtx) = 1;
  2531.         }
  2532. #if 0  /* This was turned off because, when a field is volatile
  2533.       in an object which is not volatile, the object may be in a register,
  2534.       and then we would abort over here.  */
  2535.       else
  2536.         abort ();
  2537. #endif
  2538.     }
  2539.  
  2540.       result = store_field (to_rtx, bitsize, bitpos, mode1, from,
  2541.                 (want_value
  2542.                  /* Spurious cast makes HPUX compiler happy.  */
  2543.                  ? (enum machine_mode) TYPE_MODE (TREE_TYPE (to))
  2544.                  : VOIDmode),
  2545.                 unsignedp,
  2546.                 /* Required alignment of containing datum.  */
  2547.                 alignment,
  2548.                 int_size_in_bytes (TREE_TYPE (tem)));
  2549.       preserve_temp_slots (result);
  2550.       free_temp_slots ();
  2551.       pop_temp_slots ();
  2552.  
  2553.       /* If the value is meaningful, convert RESULT to the proper mode.
  2554.      Otherwise, return nothing.  */
  2555.       return (want_value ? convert_modes (TYPE_MODE (TREE_TYPE (to)),
  2556.                       TYPE_MODE (TREE_TYPE (from)),
  2557.                       result,
  2558.                       TREE_UNSIGNED (TREE_TYPE (to)))
  2559.           : NULL_RTX);
  2560.     }
  2561.  
  2562.   /* If the rhs is a function call and its value is not an aggregate,
  2563.      call the function before we start to compute the lhs.
  2564.      This is needed for correct code for cases such as
  2565.      val = setjmp (buf) on machines where reference to val
  2566.      requires loading up part of an address in a separate insn.
  2567.  
  2568.      Don't do this if TO is a VAR_DECL whose DECL_RTL is REG since it might be
  2569.      a promoted variable where the zero- or sign- extension needs to be done.
  2570.      Handling this in the normal way is safe because no computation is done
  2571.      before the call.  */
  2572.   if (TREE_CODE (from) == CALL_EXPR && ! aggregate_value_p (from)
  2573.       && ! (TREE_CODE (to) == VAR_DECL && GET_CODE (DECL_RTL (to)) == REG))
  2574.     {
  2575.       rtx value;
  2576.  
  2577.       push_temp_slots ();
  2578.       value = expand_expr (from, NULL_RTX, VOIDmode, 0);
  2579.       if (to_rtx == 0)
  2580.     to_rtx = expand_expr (to, NULL_RTX, VOIDmode, 0);
  2581.  
  2582.       if (GET_MODE (to_rtx) == BLKmode)
  2583.     {
  2584.       int align = MIN (TYPE_ALIGN (TREE_TYPE (from)), BITS_PER_WORD);
  2585.       emit_block_move (to_rtx, value, expr_size (from), align);
  2586.     }
  2587.       else
  2588.     emit_move_insn (to_rtx, value);
  2589.       preserve_temp_slots (to_rtx);
  2590.       free_temp_slots ();
  2591.       pop_temp_slots ();
  2592.       return want_value ? to_rtx : NULL_RTX;
  2593.     }
  2594.  
  2595.   /* Ordinary treatment.  Expand TO to get a REG or MEM rtx.
  2596.      Don't re-expand if it was expanded already (in COMPONENT_REF case).  */
  2597.  
  2598.   if (to_rtx == 0)
  2599.     to_rtx = expand_expr (to, NULL_RTX, VOIDmode, 0);
  2600.  
  2601.   /* Don't move directly into a return register.  */
  2602.   if (TREE_CODE (to) == RESULT_DECL && GET_CODE (to_rtx) == REG)
  2603.     {
  2604.       rtx temp;
  2605.  
  2606.       push_temp_slots ();
  2607.       temp = expand_expr (from, 0, GET_MODE (to_rtx), 0);
  2608.       emit_move_insn (to_rtx, temp);
  2609.       preserve_temp_slots (to_rtx);
  2610.       free_temp_slots ();
  2611.       pop_temp_slots ();
  2612.       return want_value ? to_rtx : NULL_RTX;
  2613.     }
  2614.  
  2615.   /* In case we are returning the contents of an object which overlaps
  2616.      the place the value is being stored, use a safe function when copying
  2617.      a value through a pointer into a structure value return block.  */
  2618.   if (TREE_CODE (to) == RESULT_DECL && TREE_CODE (from) == INDIRECT_REF
  2619.       && current_function_returns_struct
  2620.       && !current_function_returns_pcc_struct)
  2621.     {
  2622.       rtx from_rtx, size;
  2623.  
  2624.       push_temp_slots ();
  2625.       size = expr_size (from);
  2626.       from_rtx = expand_expr (from, NULL_RTX, VOIDmode, 0);
  2627.  
  2628. #ifdef TARGET_MEM_FUNCTIONS
  2629.       emit_library_call (memcpy_libfunc, 0,
  2630.              VOIDmode, 3, XEXP (to_rtx, 0), Pmode,
  2631.              XEXP (from_rtx, 0), Pmode,
  2632.              convert_to_mode (TYPE_MODE (sizetype),
  2633.                       size, TREE_UNSIGNED (sizetype)),
  2634.              TYPE_MODE (sizetype));
  2635. #else
  2636.       emit_library_call (bcopy_libfunc, 0,
  2637.              VOIDmode, 3, XEXP (from_rtx, 0), Pmode,
  2638.              XEXP (to_rtx, 0), Pmode,
  2639.              convert_to_mode (TYPE_MODE (sizetype),
  2640.                       size, TREE_UNSIGNED (sizetype)),
  2641.              TYPE_MODE (sizetype));
  2642. #endif
  2643.  
  2644.       preserve_temp_slots (to_rtx);
  2645.       free_temp_slots ();
  2646.       pop_temp_slots ();
  2647.       return want_value ? to_rtx : NULL_RTX;
  2648.     }
  2649.  
  2650.   /* Compute FROM and store the value in the rtx we got.  */
  2651.  
  2652.   push_temp_slots ();
  2653.   result = store_expr (from, to_rtx, want_value);
  2654.   preserve_temp_slots (result);
  2655.   free_temp_slots ();
  2656.   pop_temp_slots ();
  2657.   return want_value ? result : NULL_RTX;
  2658. }
  2659.  
  2660. /* Generate code for computing expression EXP,
  2661.    and storing the value into TARGET.
  2662.    TARGET may contain a QUEUED rtx.
  2663.  
  2664.    If WANT_VALUE is nonzero, return a copy of the value
  2665.    not in TARGET, so that we can be sure to use the proper
  2666.    value in a containing expression even if TARGET has something
  2667.    else stored in it.  If possible, we copy the value through a pseudo
  2668.    and return that pseudo.  Or, if the value is constant, we try to
  2669.    return the constant.  In some cases, we return a pseudo
  2670.    copied *from* TARGET.
  2671.  
  2672.    If the mode is BLKmode then we may return TARGET itself.
  2673.    It turns out that in BLKmode it doesn't cause a problem.
  2674.    because C has no operators that could combine two different
  2675.    assignments into the same BLKmode object with different values
  2676.    with no sequence point.  Will other languages need this to
  2677.    be more thorough?
  2678.  
  2679.    If WANT_VALUE is 0, we return NULL, to make sure
  2680.    to catch quickly any cases where the caller uses the value
  2681.    and fails to set WANT_VALUE.  */
  2682.  
  2683. rtx
  2684. store_expr (exp, target, want_value)
  2685.      register tree exp;
  2686.      register rtx target;
  2687.      int want_value;
  2688. {
  2689.   register rtx temp;
  2690.   int dont_return_target = 0;
  2691.  
  2692.   if (TREE_CODE (exp) == COMPOUND_EXPR)
  2693.     {
  2694.       /* Perform first part of compound expression, then assign from second
  2695.      part.  */
  2696.       expand_expr (TREE_OPERAND (exp, 0), const0_rtx, VOIDmode, 0);
  2697.       emit_queue ();
  2698.       return store_expr (TREE_OPERAND (exp, 1), target, want_value);
  2699.     }
  2700.   else if (TREE_CODE (exp) == COND_EXPR && GET_MODE (target) == BLKmode)
  2701.     {
  2702.       /* For conditional expression, get safe form of the target.  Then
  2703.      test the condition, doing the appropriate assignment on either
  2704.      side.  This avoids the creation of unnecessary temporaries.
  2705.      For non-BLKmode, it is more efficient not to do this.  */
  2706.  
  2707.       rtx lab1 = gen_label_rtx (), lab2 = gen_label_rtx ();
  2708.  
  2709.       emit_queue ();
  2710.       target = protect_from_queue (target, 1);
  2711.  
  2712.       NO_DEFER_POP;
  2713.       jumpifnot (TREE_OPERAND (exp, 0), lab1);
  2714.       store_expr (TREE_OPERAND (exp, 1), target, 0);
  2715.       emit_queue ();
  2716.       emit_jump_insn (gen_jump (lab2));
  2717.       emit_barrier ();
  2718.       emit_label (lab1);
  2719.       store_expr (TREE_OPERAND (exp, 2), target, 0);
  2720.       emit_queue ();
  2721.       emit_label (lab2);
  2722.       OK_DEFER_POP;
  2723.       return want_value ? target : NULL_RTX;
  2724.     }
  2725.   else if (want_value && GET_CODE (target) == MEM && ! MEM_VOLATILE_P (target)
  2726.        && GET_MODE (target) != BLKmode)
  2727.     /* If target is in memory and caller wants value in a register instead,
  2728.        arrange that.  Pass TARGET as target for expand_expr so that,
  2729.        if EXP is another assignment, WANT_VALUE will be nonzero for it.
  2730.        We know expand_expr will not use the target in that case.
  2731.        Don't do this if TARGET is volatile because we are supposed
  2732.        to write it and then read it.  */
  2733.     {
  2734.       temp = expand_expr (exp, cse_not_expected ? NULL_RTX : target,
  2735.               GET_MODE (target), 0);
  2736.       if (GET_MODE (temp) != BLKmode && GET_MODE (temp) != VOIDmode)
  2737.     temp = copy_to_reg (temp);
  2738.       dont_return_target = 1;
  2739.     }
  2740.   else if (queued_subexp_p (target))
  2741.     /* If target contains a postincrement, let's not risk
  2742.        using it as the place to generate the rhs.  */
  2743.     {
  2744.       if (GET_MODE (target) != BLKmode && GET_MODE (target) != VOIDmode)
  2745.     {
  2746.       /* Expand EXP into a new pseudo.  */
  2747.       temp = gen_reg_rtx (GET_MODE (target));
  2748.       temp = expand_expr (exp, temp, GET_MODE (target), 0);
  2749.     }
  2750.       else
  2751.     temp = expand_expr (exp, NULL_RTX, GET_MODE (target), 0);
  2752.  
  2753.       /* If target is volatile, ANSI requires accessing the value
  2754.      *from* the target, if it is accessed.  So make that happen.
  2755.      In no case return the target itself.  */
  2756.       if (! MEM_VOLATILE_P (target) && want_value)
  2757.     dont_return_target = 1;
  2758.     }
  2759.   else if (GET_CODE (target) == SUBREG && SUBREG_PROMOTED_VAR_P (target))
  2760.     /* If this is an scalar in a register that is stored in a wider mode
  2761.        than the declared mode, compute the result into its declared mode
  2762.        and then convert to the wider mode.  Our value is the computed
  2763.        expression.  */
  2764.     {
  2765.       /* If we don't want a value, we can do the conversion inside EXP,
  2766.      which will often result in some optimizations.  Do the conversion
  2767.      in two steps: first change the signedness, if needed, then
  2768.      the extend.  */
  2769.       if (! want_value)
  2770.     {
  2771.       if (TREE_UNSIGNED (TREE_TYPE (exp))
  2772.           != SUBREG_PROMOTED_UNSIGNED_P (target))
  2773.         exp
  2774.           = convert
  2775.         (signed_or_unsigned_type (SUBREG_PROMOTED_UNSIGNED_P (target),
  2776.                       TREE_TYPE (exp)),
  2777.          exp);
  2778.  
  2779.       exp = convert (type_for_mode (GET_MODE (SUBREG_REG (target)),
  2780.                     SUBREG_PROMOTED_UNSIGNED_P (target)),
  2781.              exp);
  2782.     }
  2783.      
  2784.       temp = expand_expr (exp, NULL_RTX, VOIDmode, 0);
  2785.  
  2786.       /* If TEMP is a volatile MEM and we want a result value, make
  2787.      the access now so it gets done only once.  */
  2788.       if (GET_CODE (temp) == MEM && MEM_VOLATILE_P (temp) && want_value)
  2789.     temp = copy_to_reg (temp);
  2790.  
  2791.       /* If TEMP is a VOIDmode constant, use convert_modes to make
  2792.      sure that we properly convert it.  */
  2793.       if (CONSTANT_P (temp) && GET_MODE (temp) == VOIDmode)
  2794.     temp = convert_modes (GET_MODE (SUBREG_REG (target)),
  2795.                   TYPE_MODE (TREE_TYPE (exp)), temp,
  2796.                   SUBREG_PROMOTED_UNSIGNED_P (target));
  2797.  
  2798.       convert_move (SUBREG_REG (target), temp,
  2799.             SUBREG_PROMOTED_UNSIGNED_P (target));
  2800.       return want_value ? temp : NULL_RTX;
  2801.     }
  2802.   else
  2803.     {
  2804.       temp = expand_expr (exp, target, GET_MODE (target), 0);
  2805.       /* Return TARGET if it's a specified hardware register.
  2806.      If TARGET is a volatile mem ref, either return TARGET
  2807.      or return a reg copied *from* TARGET; ANSI requires this.
  2808.  
  2809.      Otherwise, if TEMP is not TARGET, return TEMP
  2810.      if it is constant (for efficiency),
  2811.      or if we really want the correct value.  */
  2812.       if (!(target && GET_CODE (target) == REG
  2813.         && REGNO (target) < FIRST_PSEUDO_REGISTER)
  2814.       && !(GET_CODE (target) == MEM && MEM_VOLATILE_P (target))
  2815.       && temp != target
  2816.       && (CONSTANT_P (temp) || want_value))
  2817.     dont_return_target = 1;
  2818.     }
  2819.  
  2820.   /* If TEMP is a VOIDmode constant and the mode of the type of EXP is not
  2821.      the same as that of TARGET, adjust the constant.  This is needed, for
  2822.      example, in case it is a CONST_DOUBLE and we want only a word-sized
  2823.      value.  */
  2824.   if (CONSTANT_P (temp) && GET_MODE (temp) == VOIDmode
  2825.       && TREE_CODE (exp) != ERROR_MARK
  2826.       && GET_MODE (target) != TYPE_MODE (TREE_TYPE (exp)))
  2827.     temp = convert_modes (GET_MODE (target), TYPE_MODE (TREE_TYPE (exp)),
  2828.               temp, TREE_UNSIGNED (TREE_TYPE (exp)));
  2829.  
  2830.   /* If value was not generated in the target, store it there.
  2831.      Convert the value to TARGET's type first if nec.  */
  2832.  
  2833.   if (temp != target && TREE_CODE (exp) != ERROR_MARK)
  2834.     {
  2835.       target = protect_from_queue (target, 1);
  2836.       if (GET_MODE (temp) != GET_MODE (target)
  2837.       && GET_MODE (temp) != VOIDmode)
  2838.     {
  2839.       int unsignedp = TREE_UNSIGNED (TREE_TYPE (exp));
  2840.       if (dont_return_target)
  2841.         {
  2842.           /* In this case, we will return TEMP,
  2843.          so make sure it has the proper mode.
  2844.          But don't forget to store the value into TARGET.  */
  2845.           temp = convert_to_mode (GET_MODE (target), temp, unsignedp);
  2846.           emit_move_insn (target, temp);
  2847.         }
  2848.       else
  2849.         convert_move (target, temp, unsignedp);
  2850.     }
  2851.  
  2852.       else if (GET_MODE (temp) == BLKmode && TREE_CODE (exp) == STRING_CST)
  2853.     {
  2854.       /* Handle copying a string constant into an array.
  2855.          The string constant may be shorter than the array.
  2856.          So copy just the string's actual length, and clear the rest.  */
  2857.       rtx size;
  2858.       rtx addr;
  2859.  
  2860.       /* Get the size of the data type of the string,
  2861.          which is actually the size of the target.  */
  2862.       size = expr_size (exp);
  2863.       if (GET_CODE (size) == CONST_INT
  2864.           && INTVAL (size) < TREE_STRING_LENGTH (exp))
  2865.         emit_block_move (target, temp, size,
  2866.                  TYPE_ALIGN (TREE_TYPE (exp)) / BITS_PER_UNIT);
  2867.       else
  2868.         {
  2869.           /* Compute the size of the data to copy from the string.  */
  2870.           tree copy_size
  2871.         = size_binop (MIN_EXPR,
  2872.                   make_tree (sizetype, size),
  2873.                   convert (sizetype,
  2874.                        build_int_2 (TREE_STRING_LENGTH (exp), 0)));
  2875.           rtx copy_size_rtx = expand_expr (copy_size, NULL_RTX,
  2876.                            VOIDmode, 0);
  2877.           rtx label = 0;
  2878.  
  2879.           /* Copy that much.  */
  2880.           emit_block_move (target, temp, copy_size_rtx,
  2881.                    TYPE_ALIGN (TREE_TYPE (exp)) / BITS_PER_UNIT);
  2882.  
  2883.           /* Figure out how much is left in TARGET that we have to clear.
  2884.          Do all calculations in ptr_mode.  */
  2885.  
  2886.           addr = XEXP (target, 0);
  2887.           addr = convert_modes (ptr_mode, Pmode, addr, 1);
  2888.  
  2889.           if (GET_CODE (copy_size_rtx) == CONST_INT)
  2890.         {
  2891.           addr = plus_constant (addr, TREE_STRING_LENGTH (exp));
  2892.           size = plus_constant (size, - TREE_STRING_LENGTH (exp));
  2893.         }
  2894.           else
  2895.         {
  2896.           addr = force_reg (ptr_mode, addr);
  2897.           addr = expand_binop (ptr_mode, add_optab, addr,
  2898.                        copy_size_rtx, NULL_RTX, 0,
  2899.                        OPTAB_LIB_WIDEN);
  2900.  
  2901.           size = expand_binop (ptr_mode, sub_optab, size,
  2902.                        copy_size_rtx, NULL_RTX, 0,
  2903.                        OPTAB_LIB_WIDEN);
  2904.  
  2905.           emit_cmp_insn (size, const0_rtx, LT, NULL_RTX,
  2906.                  GET_MODE (size), 0, 0);
  2907.           label = gen_label_rtx ();
  2908.           emit_jump_insn (gen_blt (label));
  2909.         }
  2910.  
  2911.           if (size != const0_rtx)
  2912.         {
  2913. #ifdef TARGET_MEM_FUNCTIONS
  2914.           emit_library_call (memset_libfunc, 0, VOIDmode, 3, addr,
  2915.                      Pmode, const0_rtx, Pmode, size, ptr_mode);
  2916. #else
  2917.           emit_library_call (bzero_libfunc, 0, VOIDmode, 2,
  2918.                      addr, Pmode, size, ptr_mode);
  2919. #endif
  2920.         }
  2921.  
  2922.           if (label)
  2923.         emit_label (label);
  2924.         }
  2925.     }
  2926.       else if (GET_MODE (temp) == BLKmode)
  2927.     emit_block_move (target, temp, expr_size (exp),
  2928.              TYPE_ALIGN (TREE_TYPE (exp)) / BITS_PER_UNIT);
  2929.       else
  2930.     emit_move_insn (target, temp);
  2931.     }
  2932.  
  2933.   /* If we don't want a value, return NULL_RTX.  */
  2934.   if (! want_value)
  2935.     return NULL_RTX;
  2936.  
  2937.   /* If we are supposed to return TEMP, do so as long as it isn't a MEM.
  2938.      ??? The latter test doesn't seem to make sense.  */
  2939.   else if (dont_return_target && GET_CODE (temp) != MEM)
  2940.     return temp;
  2941.  
  2942.   /* Return TARGET itself if it is a hard register.  */
  2943.   else if (want_value && GET_MODE (target) != BLKmode
  2944.        && ! (GET_CODE (target) == REG
  2945.          && REGNO (target) < FIRST_PSEUDO_REGISTER))
  2946.     return copy_to_reg (target);
  2947.   
  2948.   else
  2949.     return target;
  2950. }
  2951.  
  2952. /* Store the value of constructor EXP into the rtx TARGET.
  2953.    TARGET is either a REG or a MEM.  */
  2954.  
  2955. static void
  2956. store_constructor (exp, target)
  2957.      tree exp;
  2958.      rtx target;
  2959. {
  2960.   tree type = TREE_TYPE (exp);
  2961.  
  2962.   /* We know our target cannot conflict, since safe_from_p has been called.  */
  2963. #if 0
  2964.   /* Don't try copying piece by piece into a hard register
  2965.      since that is vulnerable to being clobbered by EXP.
  2966.      Instead, construct in a pseudo register and then copy it all.  */
  2967.   if (GET_CODE (target) == REG && REGNO (target) < FIRST_PSEUDO_REGISTER)
  2968.     {
  2969.       rtx temp = gen_reg_rtx (GET_MODE (target));
  2970.       store_constructor (exp, temp);
  2971.       emit_move_insn (target, temp);
  2972.       return;
  2973.     }
  2974. #endif
  2975.  
  2976.   if (TREE_CODE (type) == RECORD_TYPE || TREE_CODE (type) == UNION_TYPE
  2977.       || TREE_CODE (type) == QUAL_UNION_TYPE)
  2978.     {
  2979.       register tree elt;
  2980.  
  2981.       /* Inform later passes that the whole union value is dead.  */
  2982.       if (TREE_CODE (type) == UNION_TYPE
  2983.       || TREE_CODE (type) == QUAL_UNION_TYPE)
  2984.     emit_insn (gen_rtx (CLOBBER, VOIDmode, target));
  2985.  
  2986.       /* If we are building a static constructor into a register,
  2987.      set the initial value as zero so we can fold the value into
  2988.      a constant.  But if more than one register is involved,
  2989.      this probably loses.  */
  2990.       else if (GET_CODE (target) == REG && TREE_STATIC (exp)
  2991.            && GET_MODE_SIZE (GET_MODE (target)) <= UNITS_PER_WORD)
  2992.     emit_move_insn (target, const0_rtx);
  2993.  
  2994.       /* If the constructor has fewer fields than the structure,
  2995.      clear the whole structure first.  */
  2996.       else if (list_length (CONSTRUCTOR_ELTS (exp))
  2997.            != list_length (TYPE_FIELDS (type)))
  2998.     clear_storage (target, int_size_in_bytes (type));
  2999.       else
  3000.     /* Inform later passes that the old value is dead.  */
  3001.     emit_insn (gen_rtx (CLOBBER, VOIDmode, target));
  3002.  
  3003.       /* Store each element of the constructor into
  3004.      the corresponding field of TARGET.  */
  3005.  
  3006.       for (elt = CONSTRUCTOR_ELTS (exp); elt; elt = TREE_CHAIN (elt))
  3007.     {
  3008.       register tree field = TREE_PURPOSE (elt);
  3009.       register enum machine_mode mode;
  3010.       int bitsize;
  3011.       int bitpos = 0;
  3012.       int unsignedp;
  3013.       tree pos, constant = 0, offset = 0;
  3014.       rtx to_rtx = target;
  3015.  
  3016.       /* Just ignore missing fields.
  3017.          We cleared the whole structure, above,
  3018.          if any fields are missing.  */
  3019.       if (field == 0)
  3020.         continue;
  3021.  
  3022.       bitsize = TREE_INT_CST_LOW (DECL_SIZE (field));
  3023.       unsignedp = TREE_UNSIGNED (field);
  3024.       mode = DECL_MODE (field);
  3025.       if (DECL_BIT_FIELD (field))
  3026.         mode = VOIDmode;
  3027.  
  3028.       pos = DECL_FIELD_BITPOS (field);
  3029.       if (TREE_CODE (pos) == INTEGER_CST)
  3030.         constant = pos;
  3031.       else if (TREE_CODE (pos) == PLUS_EXPR
  3032.            && TREE_CODE (TREE_OPERAND (pos, 1)) == INTEGER_CST)
  3033.         constant = TREE_OPERAND (pos, 1), offset = TREE_OPERAND (pos, 0);
  3034.       else
  3035.         offset = pos;
  3036.  
  3037.       if (constant)
  3038.         bitpos = TREE_INT_CST_LOW (constant);
  3039.  
  3040.       if (offset)
  3041.         {
  3042.           rtx offset_rtx;
  3043.  
  3044.           if (contains_placeholder_p (offset))
  3045.         offset = build (WITH_RECORD_EXPR, sizetype,
  3046.                 offset, exp);
  3047.  
  3048.           offset = size_binop (FLOOR_DIV_EXPR, offset,
  3049.                    size_int (BITS_PER_UNIT));
  3050.  
  3051.           offset_rtx = expand_expr (offset, NULL_RTX, VOIDmode, 0);
  3052.           if (GET_CODE (to_rtx) != MEM)
  3053.         abort ();
  3054.  
  3055.           to_rtx
  3056.         = change_address (to_rtx, VOIDmode,
  3057.                   gen_rtx (PLUS, ptr_mode, XEXP (to_rtx, 0),
  3058.                        force_reg (ptr_mode, offset_rtx)));
  3059.         }
  3060.  
  3061.       store_field (to_rtx, bitsize, bitpos, mode, TREE_VALUE (elt),
  3062.                /* The alignment of TARGET is
  3063.               at least what its type requires.  */
  3064.                VOIDmode, 0,
  3065.                TYPE_ALIGN (type) / BITS_PER_UNIT,
  3066.                int_size_in_bytes (type));
  3067.     }
  3068.     }
  3069.   else if (TREE_CODE (type) == ARRAY_TYPE)
  3070.     {
  3071.       register tree elt;
  3072.       register int i;
  3073.       tree domain = TYPE_DOMAIN (type);
  3074.       HOST_WIDE_INT minelt = TREE_INT_CST_LOW (TYPE_MIN_VALUE (domain));
  3075.       HOST_WIDE_INT maxelt = TREE_INT_CST_LOW (TYPE_MAX_VALUE (domain));
  3076.       tree elttype = TREE_TYPE (type);
  3077.  
  3078.       /* If the constructor has fewer fields than the structure,
  3079.      clear the whole structure first.  Similarly if this this is
  3080.      static constructor of a non-BLKmode object.  */
  3081.  
  3082.       if (list_length (CONSTRUCTOR_ELTS (exp)) < maxelt - minelt + 1
  3083.       || (GET_CODE (target) == REG && TREE_STATIC (exp)))
  3084.     clear_storage (target, int_size_in_bytes (type));
  3085.       else
  3086.     /* Inform later passes that the old value is dead.  */
  3087.     emit_insn (gen_rtx (CLOBBER, VOIDmode, target));
  3088.  
  3089.       /* Store each element of the constructor into
  3090.      the corresponding element of TARGET, determined
  3091.      by counting the elements.  */
  3092.       for (elt = CONSTRUCTOR_ELTS (exp), i = 0;
  3093.        elt;
  3094.        elt = TREE_CHAIN (elt), i++)
  3095.     {
  3096.       register enum machine_mode mode;
  3097.       int bitsize;
  3098.       int bitpos;
  3099.       int unsignedp;
  3100.       tree index = TREE_PURPOSE (elt);
  3101.       rtx xtarget = target;
  3102.  
  3103.       mode = TYPE_MODE (elttype);
  3104.       bitsize = GET_MODE_BITSIZE (mode);
  3105.       unsignedp = TREE_UNSIGNED (elttype);
  3106.  
  3107.       if ((index != 0 && TREE_CODE (index) != INTEGER_CST)
  3108.           || TREE_CODE (TYPE_SIZE (elttype)) != INTEGER_CST)
  3109.         {
  3110.           rtx pos_rtx, addr, xtarget;
  3111.           tree position;
  3112.  
  3113.           if (index == 0)
  3114.         index = size_int (i);
  3115.  
  3116.           position = size_binop (EXACT_DIV_EXPR, TYPE_SIZE (elttype),
  3117.                      size_int (BITS_PER_UNIT));
  3118.           position = size_binop (MULT_EXPR, index, position);
  3119.           pos_rtx = expand_expr (position, 0, VOIDmode, 0);
  3120.           addr = gen_rtx (PLUS, Pmode, XEXP (target, 0), pos_rtx);
  3121.           xtarget = change_address (target, mode, addr);
  3122.           store_expr (TREE_VALUE (elt), xtarget, 0);
  3123.         }
  3124.       else
  3125.         {
  3126.           if (index != 0)
  3127.         bitpos = ((TREE_INT_CST_LOW (index) - minelt)
  3128.               * TREE_INT_CST_LOW (TYPE_SIZE (elttype)));
  3129.           else
  3130.         bitpos = (i * TREE_INT_CST_LOW (TYPE_SIZE (elttype)));
  3131.  
  3132.           store_field (xtarget, bitsize, bitpos, mode, TREE_VALUE (elt),
  3133.                /* The alignment of TARGET is
  3134.                   at least what its type requires.  */
  3135.                VOIDmode, 0,
  3136.                TYPE_ALIGN (type) / BITS_PER_UNIT,
  3137.                int_size_in_bytes (type));
  3138.         }
  3139.     }
  3140.     }
  3141.   /* set constructor assignments */
  3142.   else if (TREE_CODE (type) == SET_TYPE)
  3143.     {
  3144.       tree elt;
  3145.       rtx xtarget = XEXP (target, 0);
  3146.       int set_word_size = TYPE_ALIGN (type);
  3147.       int nbytes = int_size_in_bytes (type);
  3148.       tree non_const_elements;
  3149.       int need_to_clear_first;
  3150.       tree domain = TYPE_DOMAIN (type);
  3151.       tree domain_min, domain_max, bitlength;
  3152.  
  3153.       /* The default implementation strategy is to extract the constant
  3154.      parts of the constructor, use that to initialize the target,
  3155.      and then "or" in whatever non-constant ranges we need in addition.
  3156.  
  3157.      If a large set is all zero or all ones, it is
  3158.      probably better to set it using memset (if available) or bzero.
  3159.      Also, if a large set has just a single range, it may also be
  3160.      better to first clear all the first clear the set (using
  3161.      bzero/memset), and set the bits we want. */
  3162.        
  3163.       /* Check for all zeros. */
  3164.       if (CONSTRUCTOR_ELTS (exp) == NULL_TREE)
  3165.     {
  3166.       clear_storage (target, nbytes);
  3167.       return;
  3168.     }
  3169.  
  3170.       if (nbytes < 0)
  3171.     abort();
  3172.  
  3173.       domain_min = convert (sizetype, TYPE_MIN_VALUE (domain));
  3174.       domain_max = convert (sizetype, TYPE_MAX_VALUE (domain));
  3175.       bitlength = size_binop (PLUS_EXPR,
  3176.                   size_binop (MINUS_EXPR, domain_max, domain_min),
  3177.                   size_one_node);
  3178.  
  3179.       /* Check for range all ones, or at most a single range.
  3180.        (This optimization is only a win for big sets.) */
  3181.       if (GET_MODE (target) == BLKmode && nbytes > 16
  3182.       && TREE_CHAIN (CONSTRUCTOR_ELTS (exp)) == NULL_TREE)
  3183.     {
  3184.       need_to_clear_first = 1;
  3185.       non_const_elements = CONSTRUCTOR_ELTS (exp);
  3186.     }
  3187.       else
  3188.     {
  3189.       int nbits = nbytes * BITS_PER_UNIT;
  3190.       int set_word_size = TYPE_ALIGN (TREE_TYPE (exp));
  3191.       enum machine_mode mode = mode_for_size (set_word_size, MODE_INT, 1);
  3192.       char *bit_buffer = (char*) alloca (nbits);
  3193.       HOST_WIDE_INT word = 0;
  3194.       int bit_pos = 0;
  3195.       int ibit = 0;
  3196.       int offset = 0;  /* In bytes from beginning of set. */
  3197.       non_const_elements = get_set_constructor_bits (exp,
  3198.                              bit_buffer, nbits);
  3199.       for (;;)
  3200.         {
  3201.           if (bit_buffer[ibit])
  3202.         {
  3203.           if (BYTES_BIG_ENDIAN)
  3204.             word |= (1 << (set_word_size - 1 - bit_pos));
  3205.           else
  3206.             word |= 1 << bit_pos;
  3207.         }
  3208.           bit_pos++;  ibit++;
  3209.           if (bit_pos >= set_word_size || ibit == nbits)
  3210.         {
  3211.           rtx datum = GEN_INT (word);
  3212.           rtx to_rtx;
  3213.           /* The assumption here is that it is safe to use XEXP if
  3214.              the set is multi-word, but not if it's single-word. */
  3215.           if (GET_CODE (target) == MEM)
  3216.             to_rtx = change_address (target, mode,
  3217.                          plus_constant (XEXP (target, 0),
  3218.                                 offset));
  3219.           else if (offset == 0) 
  3220.             to_rtx = target;
  3221.           else
  3222.             abort ();
  3223.           emit_move_insn (to_rtx, datum);
  3224.           if (ibit == nbits)
  3225.             break;
  3226.           word = 0;
  3227.           bit_pos = 0;
  3228.           offset += set_word_size / BITS_PER_UNIT;
  3229.         }
  3230.         }
  3231.       need_to_clear_first = 0;
  3232.     }
  3233.  
  3234.       for (elt = non_const_elements; elt != NULL_TREE; elt = TREE_CHAIN (elt))
  3235.     {
  3236.       /* start of range of element or NULL */
  3237.       tree startbit = TREE_PURPOSE (elt);
  3238.       /* end of range of element, or element value */
  3239.       tree endbit   = TREE_VALUE (elt);
  3240.       HOST_WIDE_INT startb, endb;
  3241.       rtx  bitlength_rtx, startbit_rtx, endbit_rtx, targetx;
  3242.  
  3243.       bitlength_rtx = expand_expr (bitlength,
  3244.                 NULL_RTX, MEM, EXPAND_CONST_ADDRESS);
  3245.  
  3246.       /* handle non-range tuple element like [ expr ]  */
  3247.       if (startbit == NULL_TREE)
  3248.         {
  3249.           startbit = save_expr (endbit);
  3250.           endbit = startbit;
  3251.         }
  3252.       startbit = convert (sizetype, startbit);
  3253.       endbit = convert (sizetype, endbit);
  3254.       if (! integer_zerop (domain_min))
  3255.         {
  3256.           startbit = size_binop (MINUS_EXPR, startbit, domain_min);
  3257.           endbit = size_binop (MINUS_EXPR, endbit, domain_min);
  3258.         }
  3259.       startbit_rtx = expand_expr (startbit, NULL_RTX, MEM, 
  3260.                       EXPAND_CONST_ADDRESS);
  3261.       endbit_rtx = expand_expr (endbit, NULL_RTX, MEM, 
  3262.                     EXPAND_CONST_ADDRESS);
  3263.  
  3264.       if (REG_P (target))
  3265.         {
  3266.           targetx = assign_stack_temp (GET_MODE (target),
  3267.                        GET_MODE_SIZE (GET_MODE (target)),
  3268.                        0);
  3269.           emit_move_insn (targetx, target);
  3270.         }
  3271.       else if (GET_CODE (target) == MEM)
  3272.         targetx = target;
  3273.       else
  3274.         abort ();
  3275.  
  3276. #ifdef TARGET_MEM_FUNCTIONS
  3277.       /* Optimization:  If startbit and endbit are
  3278.          constants divisible by BITS_PER_UNIT,
  3279.          call memset instead. */
  3280.       if (TREE_CODE (startbit) == INTEGER_CST
  3281.           && TREE_CODE (endbit) == INTEGER_CST
  3282.           && (startb = TREE_INT_CST_LOW (startbit)) % BITS_PER_UNIT == 0
  3283.           && (endb = TREE_INT_CST_LOW (endbit)) % BITS_PER_UNIT == 0)
  3284.         {
  3285.         
  3286.           if (need_to_clear_first
  3287.           && endb - startb != nbytes * BITS_PER_UNIT)
  3288.         clear_storage (target, nbytes);
  3289.           need_to_clear_first = 0;
  3290.           emit_library_call (memset_libfunc, 0,
  3291.                  VOIDmode, 3,
  3292.                  plus_constant (XEXP (targetx, 0), startb),
  3293.                  Pmode,
  3294.                  constm1_rtx, Pmode,
  3295.                  GEN_INT ((endb - startb) / BITS_PER_UNIT),
  3296.                  Pmode);
  3297.         }
  3298.       else
  3299. #endif
  3300.         {
  3301.           if (need_to_clear_first)
  3302.         {
  3303.           clear_storage (target, nbytes);
  3304.           need_to_clear_first = 0;
  3305.         }
  3306.           emit_library_call (gen_rtx (SYMBOL_REF, Pmode, "__setbits"),
  3307.                  0, VOIDmode, 4, XEXP (targetx, 0), Pmode,
  3308.                  bitlength_rtx, TYPE_MODE (sizetype),
  3309.                  startbit_rtx, TYPE_MODE (sizetype),
  3310.                  endbit_rtx, TYPE_MODE (sizetype));
  3311.         }
  3312.       if (REG_P (target))
  3313.         emit_move_insn (target, targetx);
  3314.     }
  3315.     }
  3316.  
  3317.   else
  3318.     abort ();
  3319. }
  3320.  
  3321. /* Store the value of EXP (an expression tree)
  3322.    into a subfield of TARGET which has mode MODE and occupies
  3323.    BITSIZE bits, starting BITPOS bits from the start of TARGET.
  3324.    If MODE is VOIDmode, it means that we are storing into a bit-field.
  3325.  
  3326.    If VALUE_MODE is VOIDmode, return nothing in particular.
  3327.    UNSIGNEDP is not used in this case.
  3328.  
  3329.    Otherwise, return an rtx for the value stored.  This rtx
  3330.    has mode VALUE_MODE if that is convenient to do.
  3331.    In this case, UNSIGNEDP must be nonzero if the value is an unsigned type.
  3332.  
  3333.    ALIGN is the alignment that TARGET is known to have, measured in bytes.
  3334.    TOTAL_SIZE is the size in bytes of the structure, or -1 if varying.  */
  3335.  
  3336. static rtx
  3337. store_field (target, bitsize, bitpos, mode, exp, value_mode,
  3338.          unsignedp, align, total_size)
  3339.      rtx target;
  3340.      int bitsize, bitpos;
  3341.      enum machine_mode mode;
  3342.      tree exp;
  3343.      enum machine_mode value_mode;
  3344.      int unsignedp;
  3345.      int align;
  3346.      int total_size;
  3347. {
  3348.   HOST_WIDE_INT width_mask = 0;
  3349.  
  3350.   if (bitsize < HOST_BITS_PER_WIDE_INT)
  3351.     width_mask = ((HOST_WIDE_INT) 1 << bitsize) - 1;
  3352.  
  3353.   /* If we are storing into an unaligned field of an aligned union that is
  3354.      in a register, we may have the mode of TARGET being an integer mode but
  3355.      MODE == BLKmode.  In that case, get an aligned object whose size and
  3356.      alignment are the same as TARGET and store TARGET into it (we can avoid
  3357.      the store if the field being stored is the entire width of TARGET).  Then
  3358.      call ourselves recursively to store the field into a BLKmode version of
  3359.      that object.  Finally, load from the object into TARGET.  This is not
  3360.      very efficient in general, but should only be slightly more expensive
  3361.      than the otherwise-required unaligned accesses.  Perhaps this can be
  3362.      cleaned up later.  */
  3363.  
  3364.   if (mode == BLKmode
  3365.       && (GET_CODE (target) == REG || GET_CODE (target) == SUBREG))
  3366.     {
  3367.       rtx object = assign_stack_temp (GET_MODE (target),
  3368.                       GET_MODE_SIZE (GET_MODE (target)), 0);
  3369.       rtx blk_object = copy_rtx (object);
  3370.  
  3371.       MEM_IN_STRUCT_P (object) = 1;
  3372.       MEM_IN_STRUCT_P (blk_object) = 1;
  3373.       PUT_MODE (blk_object, BLKmode);
  3374.  
  3375.       if (bitsize != GET_MODE_BITSIZE (GET_MODE (target)))
  3376.     emit_move_insn (object, target);
  3377.  
  3378.       store_field (blk_object, bitsize, bitpos, mode, exp, VOIDmode, 0,
  3379.            align, total_size);
  3380.  
  3381.       /* Even though we aren't returning target, we need to
  3382.      give it the updated value.  */
  3383.       emit_move_insn (target, object);
  3384.  
  3385.       return blk_object;
  3386.     }
  3387.  
  3388.   /* If the structure is in a register or if the component
  3389.      is a bit field, we cannot use addressing to access it.
  3390.      Use bit-field techniques or SUBREG to store in it.  */
  3391.  
  3392.   if (mode == VOIDmode
  3393.       || (mode != BLKmode && ! direct_store[(int) mode])
  3394.       || GET_CODE (target) == REG
  3395.       || GET_CODE (target) == SUBREG
  3396.       /* If the field isn't aligned enough to store as an ordinary memref,
  3397.      store it as a bit field.  */
  3398.       || (SLOW_UNALIGNED_ACCESS
  3399.       && align * BITS_PER_UNIT < GET_MODE_ALIGNMENT (mode))
  3400.       || (SLOW_UNALIGNED_ACCESS && bitpos % GET_MODE_ALIGNMENT (mode) != 0))
  3401.     {
  3402.       rtx temp = expand_expr (exp, NULL_RTX, VOIDmode, 0);
  3403.  
  3404.       /* Unless MODE is VOIDmode or BLKmode, convert TEMP to
  3405.      MODE.  */
  3406.       if (mode != VOIDmode && mode != BLKmode
  3407.       && mode != TYPE_MODE (TREE_TYPE (exp)))
  3408.     temp = convert_modes (mode, TYPE_MODE (TREE_TYPE (exp)), temp, 1);
  3409.  
  3410.       /* Store the value in the bitfield.  */
  3411.       store_bit_field (target, bitsize, bitpos, mode, temp, align, total_size);
  3412.       if (value_mode != VOIDmode)
  3413.     {
  3414.       /* The caller wants an rtx for the value.  */
  3415.       /* If possible, avoid refetching from the bitfield itself.  */
  3416.       if (width_mask != 0
  3417.           && ! (GET_CODE (target) == MEM && MEM_VOLATILE_P (target)))
  3418.         {
  3419.           tree count;
  3420.           enum machine_mode tmode;
  3421.  
  3422.           if (unsignedp)
  3423.         return expand_and (temp, GEN_INT (width_mask), NULL_RTX);
  3424.           tmode = GET_MODE (temp);
  3425.           if (tmode == VOIDmode)
  3426.         tmode = value_mode;
  3427.           count = build_int_2 (GET_MODE_BITSIZE (tmode) - bitsize, 0);
  3428.           temp = expand_shift (LSHIFT_EXPR, tmode, temp, count, 0, 0);
  3429.           return expand_shift (RSHIFT_EXPR, tmode, temp, count, 0, 0);
  3430.         }
  3431.       return extract_bit_field (target, bitsize, bitpos, unsignedp,
  3432.                     NULL_RTX, value_mode, 0, align,
  3433.                     total_size);
  3434.     }
  3435.       return const0_rtx;
  3436.     }
  3437.   else
  3438.     {
  3439.       rtx addr = XEXP (target, 0);
  3440.       rtx to_rtx;
  3441.  
  3442.       /* If a value is wanted, it must be the lhs;
  3443.      so make the address stable for multiple use.  */
  3444.  
  3445.       if (value_mode != VOIDmode && GET_CODE (addr) != REG
  3446.       && ! CONSTANT_ADDRESS_P (addr)
  3447.       /* A frame-pointer reference is already stable.  */
  3448.       && ! (GET_CODE (addr) == PLUS
  3449.         && GET_CODE (XEXP (addr, 1)) == CONST_INT
  3450.         && (XEXP (addr, 0) == virtual_incoming_args_rtx
  3451.             || XEXP (addr, 0) == virtual_stack_vars_rtx)))
  3452.     addr = copy_to_reg (addr);
  3453.  
  3454.       /* Now build a reference to just the desired component.  */
  3455.  
  3456.       to_rtx = change_address (target, mode,
  3457.                    plus_constant (addr, (bitpos / BITS_PER_UNIT)));
  3458.       MEM_IN_STRUCT_P (to_rtx) = 1;
  3459.  
  3460.       return store_expr (exp, to_rtx, value_mode != VOIDmode);
  3461.     }
  3462. }
  3463.  
  3464. /* Return true if any object containing the innermost array is an unaligned
  3465.    packed structure field.  */
  3466.  
  3467. static int
  3468. get_inner_unaligned_p (exp)
  3469.      tree exp;
  3470. {
  3471.   int needed_alignment = TYPE_ALIGN (TREE_TYPE (exp));
  3472.  
  3473.   while (1)
  3474.     {
  3475.       if (TREE_CODE (exp) == COMPONENT_REF || TREE_CODE (exp) == BIT_FIELD_REF)
  3476.     {
  3477.       if (TYPE_ALIGN (TREE_TYPE (TREE_OPERAND (exp, 0)))
  3478.           < needed_alignment)
  3479.         return 1;
  3480.     }
  3481.       else if (TREE_CODE (exp) != ARRAY_REF
  3482.            && TREE_CODE (exp) != NON_LVALUE_EXPR
  3483.            && ! ((TREE_CODE (exp) == NOP_EXPR
  3484.               || TREE_CODE (exp) == CONVERT_EXPR)
  3485.              && (TYPE_MODE (TREE_TYPE (exp))
  3486.              == TYPE_MODE (TREE_TYPE (TREE_OPERAND (exp, 0))))))
  3487.     break;
  3488.  
  3489.       exp = TREE_OPERAND (exp, 0);
  3490.     }
  3491.  
  3492.   return 0;
  3493. }
  3494.  
  3495. /* Given an expression EXP that may be a COMPONENT_REF, a BIT_FIELD_REF,
  3496.    or an ARRAY_REF, look for nested COMPONENT_REFs, BIT_FIELD_REFs, or
  3497.    ARRAY_REFs and find the ultimate containing object, which we return.
  3498.  
  3499.    We set *PBITSIZE to the size in bits that we want, *PBITPOS to the
  3500.    bit position, and *PUNSIGNEDP to the signedness of the field.
  3501.    If the position of the field is variable, we store a tree
  3502.    giving the variable offset (in units) in *POFFSET.
  3503.    This offset is in addition to the bit position.
  3504.    If the position is not variable, we store 0 in *POFFSET.
  3505.  
  3506.    If any of the extraction expressions is volatile,
  3507.    we store 1 in *PVOLATILEP.  Otherwise we don't change that.
  3508.  
  3509.    If the field is a bit-field, *PMODE is set to VOIDmode.  Otherwise, it
  3510.    is a mode that can be used to access the field.  In that case, *PBITSIZE
  3511.    is redundant.
  3512.  
  3513.    If the field describes a variable-sized object, *PMODE is set to
  3514.    VOIDmode and *PBITSIZE is set to -1.  An access cannot be made in
  3515.    this case, but the address of the object can be found.  */
  3516.  
  3517. tree
  3518. get_inner_reference (exp, pbitsize, pbitpos, poffset, pmode,
  3519.              punsignedp, pvolatilep)
  3520.      tree exp;
  3521.      int *pbitsize;
  3522.      int *pbitpos;
  3523.      tree *poffset;
  3524.      enum machine_mode *pmode;
  3525.      int *punsignedp;
  3526.      int *pvolatilep;
  3527. {
  3528.   tree orig_exp = exp;
  3529.   tree size_tree = 0;
  3530.   enum machine_mode mode = VOIDmode;
  3531.   tree offset = integer_zero_node;
  3532.  
  3533.   if (TREE_CODE (exp) == COMPONENT_REF)
  3534.     {
  3535.       size_tree = DECL_SIZE (TREE_OPERAND (exp, 1));
  3536.       if (! DECL_BIT_FIELD (TREE_OPERAND (exp, 1)))
  3537.     mode = DECL_MODE (TREE_OPERAND (exp, 1));
  3538.       *punsignedp = TREE_UNSIGNED (TREE_OPERAND (exp, 1));
  3539.     }
  3540.   else if (TREE_CODE (exp) == BIT_FIELD_REF)
  3541.     {
  3542.       size_tree = TREE_OPERAND (exp, 1);
  3543.       *punsignedp = TREE_UNSIGNED (exp);
  3544.     }
  3545.   else
  3546.     {
  3547.       mode = TYPE_MODE (TREE_TYPE (exp));
  3548.       *pbitsize = GET_MODE_BITSIZE (mode);
  3549.       *punsignedp = TREE_UNSIGNED (TREE_TYPE (exp));
  3550.     }
  3551.       
  3552.   if (size_tree)
  3553.     {
  3554.       if (TREE_CODE (size_tree) != INTEGER_CST)
  3555.     mode = BLKmode, *pbitsize = -1;
  3556.       else
  3557.     *pbitsize = TREE_INT_CST_LOW (size_tree);
  3558.     }
  3559.  
  3560.   /* Compute cumulative bit-offset for nested component-refs and array-refs,
  3561.      and find the ultimate containing object.  */
  3562.  
  3563.   *pbitpos = 0;
  3564.  
  3565.   while (1)
  3566.     {
  3567.       if (TREE_CODE (exp) == COMPONENT_REF || TREE_CODE (exp) == BIT_FIELD_REF)
  3568.     {
  3569.       tree pos = (TREE_CODE (exp) == COMPONENT_REF
  3570.               ? DECL_FIELD_BITPOS (TREE_OPERAND (exp, 1))
  3571.               : TREE_OPERAND (exp, 2));
  3572.       tree constant = integer_zero_node, var = pos;
  3573.  
  3574.       /* If this field hasn't been filled in yet, don't go
  3575.          past it.  This should only happen when folding expressions
  3576.          made during type construction.  */
  3577.       if (pos == 0)
  3578.         break;
  3579.  
  3580.       /* Assume here that the offset is a multiple of a unit.
  3581.          If not, there should be an explicitly added constant.  */
  3582.       if (TREE_CODE (pos) == PLUS_EXPR
  3583.           && TREE_CODE (TREE_OPERAND (pos, 1)) == INTEGER_CST)
  3584.         constant = TREE_OPERAND (pos, 1), var = TREE_OPERAND (pos, 0);
  3585.       else if (TREE_CODE (pos) == INTEGER_CST)
  3586.         constant = pos, var = integer_zero_node;
  3587.  
  3588.       *pbitpos += TREE_INT_CST_LOW (constant);
  3589.  
  3590.       if (var)
  3591.         offset = size_binop (PLUS_EXPR, offset,
  3592.                  size_binop (EXACT_DIV_EXPR, var,
  3593.                          size_int (BITS_PER_UNIT)));
  3594.     }
  3595.  
  3596.       else if (TREE_CODE (exp) == ARRAY_REF)
  3597.     {
  3598.       /* This code is based on the code in case ARRAY_REF in expand_expr
  3599.          below.  We assume here that the size of an array element is
  3600.          always an integral multiple of BITS_PER_UNIT.  */
  3601.  
  3602.       tree index = TREE_OPERAND (exp, 1);
  3603.       tree domain = TYPE_DOMAIN (TREE_TYPE (TREE_OPERAND (exp, 0)));
  3604.       tree low_bound
  3605.         = domain ? TYPE_MIN_VALUE (domain) : integer_zero_node;
  3606.       tree index_type = TREE_TYPE (index);
  3607.  
  3608.       if (! integer_zerop (low_bound))
  3609.         index = fold (build (MINUS_EXPR, index_type, index, low_bound));
  3610.  
  3611.       if (TYPE_PRECISION (index_type) != POINTER_SIZE)
  3612.         {
  3613.           index = convert (type_for_size (POINTER_SIZE, 0), index);
  3614.           index_type = TREE_TYPE (index);
  3615.         }
  3616.  
  3617.       index = fold (build (MULT_EXPR, index_type, index,
  3618.                    TYPE_SIZE (TREE_TYPE (exp))));
  3619.  
  3620.       if (TREE_CODE (index) == INTEGER_CST
  3621.           && TREE_INT_CST_HIGH (index) == 0)
  3622.         *pbitpos += TREE_INT_CST_LOW (index);
  3623.       else
  3624.         offset = size_binop (PLUS_EXPR, offset,
  3625.                  size_binop (FLOOR_DIV_EXPR, index,
  3626.                          size_int (BITS_PER_UNIT)));
  3627.     }
  3628.       else if (TREE_CODE (exp) != NON_LVALUE_EXPR
  3629.            && ! ((TREE_CODE (exp) == NOP_EXPR
  3630.               || TREE_CODE (exp) == CONVERT_EXPR)
  3631.              && ! (TREE_CODE (TREE_TYPE (exp)) == UNION_TYPE
  3632.                && (TREE_CODE (TREE_TYPE (TREE_OPERAND (exp, 0)))
  3633.                    != UNION_TYPE))
  3634.              && (TYPE_MODE (TREE_TYPE (exp))
  3635.              == TYPE_MODE (TREE_TYPE (TREE_OPERAND (exp, 0))))))
  3636.     break;
  3637.  
  3638.       /* If any reference in the chain is volatile, the effect is volatile.  */
  3639.       if (TREE_THIS_VOLATILE (exp))
  3640.     *pvolatilep = 1;
  3641.       exp = TREE_OPERAND (exp, 0);
  3642.     }
  3643.  
  3644.   /* If this was a bit-field, see if there is a mode that allows direct
  3645.      access in case EXP is in memory.  */
  3646.   if (mode == VOIDmode && *pbitsize != 0 && *pbitpos % *pbitsize == 0)
  3647.     {
  3648.       mode = mode_for_size (*pbitsize, MODE_INT, 0);
  3649.       if (mode == BLKmode)
  3650.     mode = VOIDmode;
  3651.     }
  3652.  
  3653.   if (integer_zerop (offset))
  3654.     offset = 0;
  3655.  
  3656.   if (offset != 0 && contains_placeholder_p (offset))
  3657.     offset = build (WITH_RECORD_EXPR, sizetype, offset, orig_exp);
  3658.  
  3659.   *pmode = mode;
  3660.   *poffset = offset;
  3661.   return exp;
  3662. }
  3663.  
  3664. /* Given an rtx VALUE that may contain additions and multiplications,
  3665.    return an equivalent value that just refers to a register or memory.
  3666.    This is done by generating instructions to perform the arithmetic
  3667.    and returning a pseudo-register containing the value.
  3668.  
  3669.    The returned value may be a REG, SUBREG, MEM or constant.  */
  3670.  
  3671. rtx
  3672. force_operand (value, target)
  3673.      rtx value, target;
  3674. {
  3675.   register optab binoptab = 0;
  3676.   /* Use a temporary to force order of execution of calls to
  3677.      `force_operand'.  */
  3678.   rtx tmp;
  3679.   register rtx op2;
  3680.   /* Use subtarget as the target for operand 0 of a binary operation.  */
  3681.   register rtx subtarget = (target != 0 && GET_CODE (target) == REG ? target : 0);
  3682.  
  3683.   if (GET_CODE (value) == PLUS)
  3684.     binoptab = add_optab;
  3685.   else if (GET_CODE (value) == MINUS)
  3686.     binoptab = sub_optab;
  3687.   else if (GET_CODE (value) == MULT)
  3688.     {
  3689.       op2 = XEXP (value, 1);
  3690.       if (!CONSTANT_P (op2)
  3691.       && !(GET_CODE (op2) == REG && op2 != subtarget))
  3692.     subtarget = 0;
  3693.       tmp = force_operand (XEXP (value, 0), subtarget);
  3694.       return expand_mult (GET_MODE (value), tmp,
  3695.               force_operand (op2, NULL_RTX),
  3696.               target, 0);
  3697.     }
  3698.  
  3699.   if (binoptab)
  3700.     {
  3701.       op2 = XEXP (value, 1);
  3702.       if (!CONSTANT_P (op2)
  3703.       && !(GET_CODE (op2) == REG && op2 != subtarget))
  3704.     subtarget = 0;
  3705.       if (binoptab == sub_optab && GET_CODE (op2) == CONST_INT)
  3706.     {
  3707.       binoptab = add_optab;
  3708.       op2 = negate_rtx (GET_MODE (value), op2);
  3709.     }
  3710.  
  3711.       /* Check for an addition with OP2 a constant integer and our first
  3712.      operand a PLUS of a virtual register and something else.  In that
  3713.      case, we want to emit the sum of the virtual register and the
  3714.      constant first and then add the other value.  This allows virtual
  3715.      register instantiation to simply modify the constant rather than
  3716.      creating another one around this addition.  */
  3717.       if (binoptab == add_optab && GET_CODE (op2) == CONST_INT
  3718.       && GET_CODE (XEXP (value, 0)) == PLUS
  3719.       && GET_CODE (XEXP (XEXP (value, 0), 0)) == REG
  3720.       && REGNO (XEXP (XEXP (value, 0), 0)) >= FIRST_VIRTUAL_REGISTER
  3721.       && REGNO (XEXP (XEXP (value, 0), 0)) <= LAST_VIRTUAL_REGISTER)
  3722.     {
  3723.       rtx temp = expand_binop (GET_MODE (value), binoptab,
  3724.                    XEXP (XEXP (value, 0), 0), op2,
  3725.                    subtarget, 0, OPTAB_LIB_WIDEN);
  3726.       return expand_binop (GET_MODE (value), binoptab, temp,
  3727.                    force_operand (XEXP (XEXP (value, 0), 1), 0),
  3728.                    target, 0, OPTAB_LIB_WIDEN);
  3729.     }
  3730.                    
  3731.       tmp = force_operand (XEXP (value, 0), subtarget);
  3732.       return expand_binop (GET_MODE (value), binoptab, tmp,
  3733.                force_operand (op2, NULL_RTX),
  3734.                target, 0, OPTAB_LIB_WIDEN);
  3735.       /* We give UNSIGNEDP = 0 to expand_binop
  3736.      because the only operations we are expanding here are signed ones.  */
  3737.     }
  3738.   return value;
  3739. }
  3740.  
  3741. /* Subroutine of expand_expr:
  3742.    save the non-copied parts (LIST) of an expr (LHS), and return a list
  3743.    which can restore these values to their previous values,
  3744.    should something modify their storage.  */
  3745.  
  3746. static tree
  3747. save_noncopied_parts (lhs, list)
  3748.      tree lhs;
  3749.      tree list;
  3750. {
  3751.   tree tail;
  3752.   tree parts = 0;
  3753.  
  3754.   for (tail = list; tail; tail = TREE_CHAIN (tail))
  3755.     if (TREE_CODE (TREE_VALUE (tail)) == TREE_LIST)
  3756.       parts = chainon (parts, save_noncopied_parts (lhs, TREE_VALUE (tail)));
  3757.     else
  3758.       {
  3759.     tree part = TREE_VALUE (tail);
  3760.     tree part_type = TREE_TYPE (part);
  3761.     tree to_be_saved = build (COMPONENT_REF, part_type, lhs, part);
  3762.     rtx target = assign_stack_temp (TYPE_MODE (part_type),
  3763.                     int_size_in_bytes (part_type), 0);
  3764.     MEM_IN_STRUCT_P (target) = AGGREGATE_TYPE_P (part_type);
  3765.     if (! memory_address_p (TYPE_MODE (part_type), XEXP (target, 0)))
  3766.       target = change_address (target, TYPE_MODE (part_type), NULL_RTX);
  3767.     parts = tree_cons (to_be_saved,
  3768.                build (RTL_EXPR, part_type, NULL_TREE,
  3769.                   (tree) target),
  3770.                parts);
  3771.     store_expr (TREE_PURPOSE (parts), RTL_EXPR_RTL (TREE_VALUE (parts)), 0);
  3772.       }
  3773.   return parts;
  3774. }
  3775.  
  3776. /* Subroutine of expand_expr:
  3777.    record the non-copied parts (LIST) of an expr (LHS), and return a list
  3778.    which specifies the initial values of these parts.  */
  3779.  
  3780. static tree
  3781. init_noncopied_parts (lhs, list)
  3782.      tree lhs;
  3783.      tree list;
  3784. {
  3785.   tree tail;
  3786.   tree parts = 0;
  3787.  
  3788.   for (tail = list; tail; tail = TREE_CHAIN (tail))
  3789.     if (TREE_CODE (TREE_VALUE (tail)) == TREE_LIST)
  3790.       parts = chainon (parts, init_noncopied_parts (lhs, TREE_VALUE (tail)));
  3791.     else
  3792.       {
  3793.     tree part = TREE_VALUE (tail);
  3794.     tree part_type = TREE_TYPE (part);
  3795.     tree to_be_initialized = build (COMPONENT_REF, part_type, lhs, part);
  3796.     parts = tree_cons (TREE_PURPOSE (tail), to_be_initialized, parts);
  3797.       }
  3798.   return parts;
  3799. }
  3800.  
  3801. /* Subroutine of expand_expr: return nonzero iff there is no way that
  3802.    EXP can reference X, which is being modified.  */
  3803.  
  3804. static int
  3805. safe_from_p (x, exp)
  3806.      rtx x;
  3807.      tree exp;
  3808. {
  3809.   rtx exp_rtl = 0;
  3810.   int i, nops;
  3811.  
  3812.   if (x == 0
  3813.       /* If EXP has varying size, we MUST use a target since we currently
  3814.      have no way of allocating temporaries of variable size.  So we
  3815.      assume here that something at a higher level has prevented a
  3816.      clash.  This is somewhat bogus, but the best we can do.  */
  3817.       || (TREE_TYPE (exp) != 0 && TYPE_SIZE (TREE_TYPE (exp)) != 0
  3818.       && TREE_CODE (TYPE_SIZE (TREE_TYPE (exp))) != INTEGER_CST))
  3819.     return 1;
  3820.  
  3821.   /* If this is a subreg of a hard register, declare it unsafe, otherwise,
  3822.      find the underlying pseudo.  */
  3823.   if (GET_CODE (x) == SUBREG)
  3824.     {
  3825.       x = SUBREG_REG (x);
  3826.       if (GET_CODE (x) == REG && REGNO (x) < FIRST_PSEUDO_REGISTER)
  3827.     return 0;
  3828.     }
  3829.  
  3830.   /* If X is a location in the outgoing argument area, it is always safe.  */
  3831.   if (GET_CODE (x) == MEM
  3832.       && (XEXP (x, 0) == virtual_outgoing_args_rtx
  3833.       || (GET_CODE (XEXP (x, 0)) == PLUS
  3834.           && XEXP (XEXP (x, 0), 0) == virtual_outgoing_args_rtx)))
  3835.     return 1;
  3836.  
  3837.   switch (TREE_CODE_CLASS (TREE_CODE (exp)))
  3838.     {
  3839.     case 'd':
  3840.       exp_rtl = DECL_RTL (exp);
  3841.       break;
  3842.  
  3843.     case 'c':
  3844.       return 1;
  3845.  
  3846.     case 'x':
  3847.       if (TREE_CODE (exp) == TREE_LIST)
  3848.     return ((TREE_VALUE (exp) == 0
  3849.          || safe_from_p (x, TREE_VALUE (exp)))
  3850.         && (TREE_CHAIN (exp) == 0
  3851.             || safe_from_p (x, TREE_CHAIN (exp))));
  3852.       else
  3853.     return 0;
  3854.  
  3855.     case '1':
  3856.       return safe_from_p (x, TREE_OPERAND (exp, 0));
  3857.  
  3858.     case '2':
  3859.     case '<':
  3860.       return (safe_from_p (x, TREE_OPERAND (exp, 0))
  3861.           && safe_from_p (x, TREE_OPERAND (exp, 1)));
  3862.  
  3863.     case 'e':
  3864.     case 'r':
  3865.       /* Now do code-specific tests.  EXP_RTL is set to any rtx we find in
  3866.      the expression.  If it is set, we conflict iff we are that rtx or
  3867.      both are in memory.  Otherwise, we check all operands of the
  3868.      expression recursively.  */
  3869.  
  3870.       switch (TREE_CODE (exp))
  3871.     {
  3872.     case ADDR_EXPR:
  3873.       return (staticp (TREE_OPERAND (exp, 0))
  3874.           || safe_from_p (x, TREE_OPERAND (exp, 0)));
  3875.  
  3876.     case INDIRECT_REF:
  3877.       if (GET_CODE (x) == MEM)
  3878.         return 0;
  3879.       break;
  3880.  
  3881.     case CALL_EXPR:
  3882.       exp_rtl = CALL_EXPR_RTL (exp);
  3883.       if (exp_rtl == 0)
  3884.         {
  3885.           /* Assume that the call will clobber all hard registers and
  3886.          all of memory.  */
  3887.           if ((GET_CODE (x) == REG && REGNO (x) < FIRST_PSEUDO_REGISTER)
  3888.           || GET_CODE (x) == MEM)
  3889.         return 0;
  3890.         }
  3891.  
  3892.       break;
  3893.  
  3894.     case RTL_EXPR:
  3895.       exp_rtl = RTL_EXPR_RTL (exp);
  3896.       if (exp_rtl == 0)
  3897.         /* We don't know what this can modify.  */
  3898.         return 0;
  3899.  
  3900.       break;
  3901.  
  3902.     case WITH_CLEANUP_EXPR:
  3903.       exp_rtl = RTL_EXPR_RTL (exp);
  3904.       break;
  3905.  
  3906.     case CLEANUP_POINT_EXPR:
  3907.       return safe_from_p (x, TREE_OPERAND (exp, 0));
  3908.  
  3909.     case SAVE_EXPR:
  3910.       exp_rtl = SAVE_EXPR_RTL (exp);
  3911.       break;
  3912.  
  3913.     case BIND_EXPR:
  3914.       /* The only operand we look at is operand 1.  The rest aren't
  3915.          part of the expression.  */
  3916.       return safe_from_p (x, TREE_OPERAND (exp, 1));
  3917.  
  3918.     case METHOD_CALL_EXPR:
  3919.       /* This takes a rtx argument, but shouldn't appear here. */
  3920.       abort ();
  3921.     }
  3922.  
  3923.       /* If we have an rtx, we do not need to scan our operands.  */
  3924.       if (exp_rtl)
  3925.     break;
  3926.  
  3927.       nops = tree_code_length[(int) TREE_CODE (exp)];
  3928.       for (i = 0; i < nops; i++)
  3929.     if (TREE_OPERAND (exp, i) != 0
  3930.         && ! safe_from_p (x, TREE_OPERAND (exp, i)))
  3931.       return 0;
  3932.     }
  3933.  
  3934.   /* If we have an rtl, find any enclosed object.  Then see if we conflict
  3935.      with it.  */
  3936.   if (exp_rtl)
  3937.     {
  3938.       if (GET_CODE (exp_rtl) == SUBREG)
  3939.     {
  3940.       exp_rtl = SUBREG_REG (exp_rtl);
  3941.       if (GET_CODE (exp_rtl) == REG
  3942.           && REGNO (exp_rtl) < FIRST_PSEUDO_REGISTER)
  3943.         return 0;
  3944.     }
  3945.  
  3946.       /* If the rtl is X, then it is not safe.  Otherwise, it is unless both
  3947.      are memory and EXP is not readonly.  */
  3948.       return ! (rtx_equal_p (x, exp_rtl)
  3949.         || (GET_CODE (x) == MEM && GET_CODE (exp_rtl) == MEM
  3950.             && ! TREE_READONLY (exp)));
  3951.     }
  3952.  
  3953.   /* If we reach here, it is safe.  */
  3954.   return 1;
  3955. }
  3956.  
  3957. /* Subroutine of expand_expr: return nonzero iff EXP is an
  3958.    expression whose type is statically determinable.  */
  3959.  
  3960. static int
  3961. fixed_type_p (exp)
  3962.      tree exp;
  3963. {
  3964.   if (TREE_CODE (exp) == PARM_DECL
  3965.       || TREE_CODE (exp) == VAR_DECL
  3966.       || TREE_CODE (exp) == CALL_EXPR || TREE_CODE (exp) == TARGET_EXPR
  3967.       || TREE_CODE (exp) == COMPONENT_REF
  3968.       || TREE_CODE (exp) == ARRAY_REF)
  3969.     return 1;
  3970.   return 0;
  3971. }
  3972.  
  3973. /* expand_expr: generate code for computing expression EXP.
  3974.    An rtx for the computed value is returned.  The value is never null.
  3975.    In the case of a void EXP, const0_rtx is returned.
  3976.  
  3977.    The value may be stored in TARGET if TARGET is nonzero.
  3978.    TARGET is just a suggestion; callers must assume that
  3979.    the rtx returned may not be the same as TARGET.
  3980.  
  3981.    If TARGET is CONST0_RTX, it means that the value will be ignored.
  3982.  
  3983.    If TMODE is not VOIDmode, it suggests generating the
  3984.    result in mode TMODE.  But this is done only when convenient.
  3985.    Otherwise, TMODE is ignored and the value generated in its natural mode.
  3986.    TMODE is just a suggestion; callers must assume that
  3987.    the rtx returned may not have mode TMODE.
  3988.  
  3989.    Note that TARGET may have neither TMODE nor MODE.  In that case, it
  3990.    probably will not be used.
  3991.  
  3992.    If MODIFIER is EXPAND_SUM then when EXP is an addition
  3993.    we can return an rtx of the form (MULT (REG ...) (CONST_INT ...))
  3994.    or a nest of (PLUS ...) and (MINUS ...) where the terms are
  3995.    products as above, or REG or MEM, or constant.
  3996.    Ordinarily in such cases we would output mul or add instructions
  3997.    and then return a pseudo reg containing the sum.
  3998.  
  3999.    EXPAND_INITIALIZER is much like EXPAND_SUM except that
  4000.    it also marks a label as absolutely required (it can't be dead).
  4001.    It also makes a ZERO_EXTEND or SIGN_EXTEND instead of emitting extend insns.
  4002.    This is used for outputting expressions used in initializers.
  4003.  
  4004.    EXPAND_CONST_ADDRESS says that it is okay to return a MEM
  4005.    with a constant address even if that address is not normally legitimate.
  4006.    EXPAND_INITIALIZER and EXPAND_SUM also have this effect.  */
  4007.  
  4008. rtx
  4009. expand_expr (exp, target, tmode, modifier)
  4010.      register tree exp;
  4011.      rtx target;
  4012.      enum machine_mode tmode;
  4013.      enum expand_modifier modifier;
  4014. {
  4015.   /* Chain of pending expressions for PLACEHOLDER_EXPR to replace.
  4016.      This is static so it will be accessible to our recursive callees.  */
  4017.   static tree placeholder_list = 0;
  4018.   register rtx op0, op1, temp;
  4019.   tree type = TREE_TYPE (exp);
  4020.   int unsignedp = TREE_UNSIGNED (type);
  4021.   register enum machine_mode mode = TYPE_MODE (type);
  4022.   register enum tree_code code = TREE_CODE (exp);
  4023.   optab this_optab;
  4024.   /* Use subtarget as the target for operand 0 of a binary operation.  */
  4025.   rtx subtarget = (target != 0 && GET_CODE (target) == REG ? target : 0);
  4026.   rtx original_target = target;
  4027.   /* Maybe defer this until sure not doing bytecode?  */
  4028.   int ignore = (target == const0_rtx
  4029.         || ((code == NON_LVALUE_EXPR || code == NOP_EXPR
  4030.              || code == CONVERT_EXPR || code == REFERENCE_EXPR
  4031.              || code == COND_EXPR)
  4032.             && TREE_CODE (type) == VOID_TYPE));
  4033.   tree context;
  4034.  
  4035.  
  4036.   if (output_bytecode && modifier != EXPAND_INITIALIZER)
  4037.     {
  4038.       bc_expand_expr (exp);
  4039.       return NULL;
  4040.     }
  4041.  
  4042.   /* Don't use hard regs as subtargets, because the combiner
  4043.      can only handle pseudo regs.  */
  4044.   if (subtarget && REGNO (subtarget) < FIRST_PSEUDO_REGISTER)
  4045.     subtarget = 0;
  4046.   /* Avoid subtargets inside loops,
  4047.      since they hide some invariant expressions.  */
  4048.   if (preserve_subexpressions_p ())
  4049.     subtarget = 0;
  4050.  
  4051.   /* If we are going to ignore this result, we need only do something
  4052.      if there is a side-effect somewhere in the expression.  If there
  4053.      is, short-circuit the most common cases here.  Note that we must
  4054.      not call expand_expr with anything but const0_rtx in case this
  4055.      is an initial expansion of a size that contains a PLACEHOLDER_EXPR.  */
  4056.  
  4057.   if (ignore)
  4058.     {
  4059.       if (! TREE_SIDE_EFFECTS (exp))
  4060.     return const0_rtx;
  4061.  
  4062.       /* Ensure we reference a volatile object even if value is ignored.  */
  4063.       if (TREE_THIS_VOLATILE (exp)
  4064.       && TREE_CODE (exp) != FUNCTION_DECL
  4065.       && mode != VOIDmode && mode != BLKmode)
  4066.     {
  4067.       temp = expand_expr (exp, NULL_RTX, VOIDmode, modifier);
  4068.       if (GET_CODE (temp) == MEM)
  4069.         temp = copy_to_reg (temp);
  4070.       return const0_rtx;
  4071.     }
  4072.  
  4073.       if (TREE_CODE_CLASS (code) == '1')
  4074.     return expand_expr (TREE_OPERAND (exp, 0), const0_rtx,
  4075.                 VOIDmode, modifier);
  4076.       else if (TREE_CODE_CLASS (code) == '2'
  4077.            || TREE_CODE_CLASS (code) == '<')
  4078.     {
  4079.       expand_expr (TREE_OPERAND (exp, 0), const0_rtx, VOIDmode, modifier);
  4080.       expand_expr (TREE_OPERAND (exp, 1), const0_rtx, VOIDmode, modifier);
  4081.       return const0_rtx;
  4082.     }
  4083.       else if ((code == TRUTH_ANDIF_EXPR || code == TRUTH_ORIF_EXPR)
  4084.            && ! TREE_SIDE_EFFECTS (TREE_OPERAND (exp, 1)))
  4085.     /* If the second operand has no side effects, just evaluate
  4086.        the first. */
  4087.     return expand_expr (TREE_OPERAND (exp, 0), const0_rtx,
  4088.                 VOIDmode, modifier);
  4089.  
  4090.       target = 0;
  4091.     }
  4092.  
  4093.   /* If will do cse, generate all results into pseudo registers
  4094.      since 1) that allows cse to find more things
  4095.      and 2) otherwise cse could produce an insn the machine
  4096.      cannot support.  */
  4097.  
  4098.   if (! cse_not_expected && mode != BLKmode && target
  4099.       && (GET_CODE (target) != REG || REGNO (target) < FIRST_PSEUDO_REGISTER))
  4100.     target = subtarget;
  4101.  
  4102.   switch (code)
  4103.     {
  4104.     case LABEL_DECL:
  4105.       {
  4106.     tree function = decl_function_context (exp);
  4107.     /* Handle using a label in a containing function.  */
  4108.     if (function != current_function_decl && function != 0)
  4109.       {
  4110.         struct function *p = find_function_data (function);
  4111.         /* Allocate in the memory associated with the function
  4112.            that the label is in.  */
  4113.         push_obstacks (p->function_obstack,
  4114.                p->function_maybepermanent_obstack);
  4115.  
  4116.         p->forced_labels = gen_rtx (EXPR_LIST, VOIDmode,
  4117.                     label_rtx (exp), p->forced_labels);
  4118.         pop_obstacks ();
  4119.       }
  4120.     else if (modifier == EXPAND_INITIALIZER)
  4121.       forced_labels = gen_rtx (EXPR_LIST, VOIDmode,
  4122.                    label_rtx (exp), forced_labels);
  4123.     temp = gen_rtx (MEM, FUNCTION_MODE,
  4124.             gen_rtx (LABEL_REF, Pmode, label_rtx (exp)));
  4125.     if (function != current_function_decl && function != 0)
  4126.       LABEL_REF_NONLOCAL_P (XEXP (temp, 0)) = 1;
  4127.     return temp;
  4128.       }
  4129.  
  4130.     case PARM_DECL:
  4131.       if (DECL_RTL (exp) == 0)
  4132.     {
  4133.       error_with_decl (exp, "prior parameter's size depends on `%s'");
  4134.       return CONST0_RTX (mode);
  4135.     }
  4136.  
  4137.       /* ... fall through ... */
  4138.  
  4139.     case VAR_DECL:
  4140.       /* If a static var's type was incomplete when the decl was written,
  4141.      but the type is complete now, lay out the decl now.  */
  4142.       if (DECL_SIZE (exp) == 0 && TYPE_SIZE (TREE_TYPE (exp)) != 0
  4143.       && (TREE_STATIC (exp) || DECL_EXTERNAL (exp)))
  4144.     {
  4145.       push_obstacks_nochange ();
  4146.       end_temporary_allocation ();
  4147.       layout_decl (exp, 0);
  4148.       PUT_MODE (DECL_RTL (exp), DECL_MODE (exp));
  4149.       pop_obstacks ();
  4150.     }
  4151.  
  4152.       /* ... fall through ... */
  4153.  
  4154.     case FUNCTION_DECL:
  4155.     case RESULT_DECL:
  4156.       if (DECL_RTL (exp) == 0)
  4157.     abort ();
  4158.  
  4159.       /* Ensure variable marked as used even if it doesn't go through
  4160.      a parser.  If it hasn't be used yet, write out an external
  4161.      definition.  */
  4162.       if (! TREE_USED (exp))
  4163.     {
  4164.       assemble_external (exp);
  4165.       TREE_USED (exp) = 1;
  4166.     }
  4167.  
  4168.       /* Handle variables inherited from containing functions.  */
  4169.       context = decl_function_context (exp);
  4170.  
  4171.       /* We treat inline_function_decl as an alias for the current function
  4172.      because that is the inline function whose vars, types, etc.
  4173.      are being merged into the current function.
  4174.      See expand_inline_function.  */
  4175.  
  4176.       if (context != 0 && context != current_function_decl
  4177.       && context != inline_function_decl
  4178.       /* If var is static, we don't need a static chain to access it.  */
  4179.       && ! (GET_CODE (DECL_RTL (exp)) == MEM
  4180.         && CONSTANT_P (XEXP (DECL_RTL (exp), 0))))
  4181.     {
  4182.       rtx addr;
  4183.  
  4184.       /* Mark as non-local and addressable.  */
  4185.       DECL_NONLOCAL (exp) = 1;
  4186.       mark_addressable (exp);
  4187.       if (GET_CODE (DECL_RTL (exp)) != MEM)
  4188.         abort ();
  4189.       addr = XEXP (DECL_RTL (exp), 0);
  4190.       if (GET_CODE (addr) == MEM)
  4191.         addr = gen_rtx (MEM, Pmode,
  4192.                 fix_lexical_addr (XEXP (addr, 0), exp));
  4193.       else
  4194.         addr = fix_lexical_addr (addr, exp);
  4195.       return change_address (DECL_RTL (exp), mode, addr);
  4196.     }
  4197.  
  4198.       /* This is the case of an array whose size is to be determined
  4199.      from its initializer, while the initializer is still being parsed.
  4200.      See expand_decl.  */
  4201.  
  4202.       if (GET_CODE (DECL_RTL (exp)) == MEM
  4203.       && GET_CODE (XEXP (DECL_RTL (exp), 0)) == REG)
  4204.     return change_address (DECL_RTL (exp), GET_MODE (DECL_RTL (exp)),
  4205.                    XEXP (DECL_RTL (exp), 0));
  4206.  
  4207.       /* If DECL_RTL is memory, we are in the normal case and either
  4208.      the address is not valid or it is not a register and -fforce-addr
  4209.      is specified, get the address into a register.  */
  4210.  
  4211.       if (GET_CODE (DECL_RTL (exp)) == MEM
  4212.       && modifier != EXPAND_CONST_ADDRESS
  4213.       && modifier != EXPAND_SUM
  4214.       && modifier != EXPAND_INITIALIZER
  4215.       && (! memory_address_p (DECL_MODE (exp), XEXP (DECL_RTL (exp), 0))
  4216.           || (flag_force_addr
  4217.           && GET_CODE (XEXP (DECL_RTL (exp), 0)) != REG)))
  4218.     return change_address (DECL_RTL (exp), VOIDmode,
  4219.                    copy_rtx (XEXP (DECL_RTL (exp), 0)));
  4220.  
  4221.       /* If the mode of DECL_RTL does not match that of the decl, it
  4222.      must be a promoted value.  We return a SUBREG of the wanted mode,
  4223.      but mark it so that we know that it was already extended.  */
  4224.  
  4225.       if (GET_CODE (DECL_RTL (exp)) == REG
  4226.       && GET_MODE (DECL_RTL (exp)) != mode)
  4227.     {
  4228.       /* Get the signedness used for this variable.  Ensure we get the
  4229.          same mode we got when the variable was declared.  */
  4230.       if (GET_MODE (DECL_RTL (exp))
  4231.           != promote_mode (type, DECL_MODE (exp), &unsignedp, 0))
  4232.         abort ();
  4233.  
  4234.       temp = gen_rtx (SUBREG, mode, DECL_RTL (exp), 0);
  4235.       SUBREG_PROMOTED_VAR_P (temp) = 1;
  4236.       SUBREG_PROMOTED_UNSIGNED_P (temp) = unsignedp;
  4237.       return temp;
  4238.     }
  4239.  
  4240.       return DECL_RTL (exp);
  4241.  
  4242.     case INTEGER_CST:
  4243.       return immed_double_const (TREE_INT_CST_LOW (exp),
  4244.                  TREE_INT_CST_HIGH (exp),
  4245.                  mode);
  4246.  
  4247.     case CONST_DECL:
  4248.       return expand_expr (DECL_INITIAL (exp), target, VOIDmode, 0);
  4249.  
  4250.     case REAL_CST:
  4251.       /* If optimized, generate immediate CONST_DOUBLE
  4252.      which will be turned into memory by reload if necessary. 
  4253.      
  4254.      We used to force a register so that loop.c could see it.  But
  4255.      this does not allow gen_* patterns to perform optimizations with
  4256.      the constants.  It also produces two insns in cases like "x = 1.0;".
  4257.      On most machines, floating-point constants are not permitted in
  4258.      many insns, so we'd end up copying it to a register in any case.
  4259.  
  4260.      Now, we do the copying in expand_binop, if appropriate.  */
  4261.       return immed_real_const (exp);
  4262.  
  4263.     case COMPLEX_CST:
  4264.     case STRING_CST:
  4265.       if (! TREE_CST_RTL (exp))
  4266.     output_constant_def (exp);
  4267.  
  4268.       /* TREE_CST_RTL probably contains a constant address.
  4269.      On RISC machines where a constant address isn't valid,
  4270.      make some insns to get that address into a register.  */
  4271.       if (GET_CODE (TREE_CST_RTL (exp)) == MEM
  4272.       && modifier != EXPAND_CONST_ADDRESS
  4273.       && modifier != EXPAND_INITIALIZER
  4274.       && modifier != EXPAND_SUM
  4275.       && (! memory_address_p (mode, XEXP (TREE_CST_RTL (exp), 0))
  4276.           || (flag_force_addr
  4277.           && GET_CODE (XEXP (TREE_CST_RTL (exp), 0)) != REG)))
  4278.     return change_address (TREE_CST_RTL (exp), VOIDmode,
  4279.                    copy_rtx (XEXP (TREE_CST_RTL (exp), 0)));
  4280.       return TREE_CST_RTL (exp);
  4281.  
  4282.     case SAVE_EXPR:
  4283.       context = decl_function_context (exp);
  4284.  
  4285.       /* We treat inline_function_decl as an alias for the current function
  4286.      because that is the inline function whose vars, types, etc.
  4287.      are being merged into the current function.
  4288.      See expand_inline_function.  */
  4289.       if (context == current_function_decl || context == inline_function_decl)
  4290.     context = 0;
  4291.  
  4292.       /* If this is non-local, handle it.  */
  4293.       if (context)
  4294.     {
  4295.       temp = SAVE_EXPR_RTL (exp);
  4296.       if (temp && GET_CODE (temp) == REG)
  4297.         {
  4298.           put_var_into_stack (exp);
  4299.           temp = SAVE_EXPR_RTL (exp);
  4300.         }
  4301.       if (temp == 0 || GET_CODE (temp) != MEM)
  4302.         abort ();
  4303.       return change_address (temp, mode,
  4304.                  fix_lexical_addr (XEXP (temp, 0), exp));
  4305.     }
  4306.       if (SAVE_EXPR_RTL (exp) == 0)
  4307.     {
  4308.       if (mode == BLKmode)
  4309.         {
  4310.           temp
  4311.         = assign_stack_temp (mode, int_size_in_bytes (type), 0);
  4312.           MEM_IN_STRUCT_P (temp) = AGGREGATE_TYPE_P (type);
  4313.         }
  4314.       else if (mode == VOIDmode)
  4315.         temp = const0_rtx;
  4316.       else
  4317.         temp = gen_reg_rtx (promote_mode (type, mode, &unsignedp, 0));
  4318.  
  4319.       SAVE_EXPR_RTL (exp) = temp;
  4320.       if (!optimize && GET_CODE (temp) == REG)
  4321.         save_expr_regs = gen_rtx (EXPR_LIST, VOIDmode, temp,
  4322.                       save_expr_regs);
  4323.  
  4324.       /* If the mode of TEMP does not match that of the expression, it
  4325.          must be a promoted value.  We pass store_expr a SUBREG of the
  4326.          wanted mode but mark it so that we know that it was already
  4327.          extended.  Note that `unsignedp' was modified above in
  4328.          this case.  */
  4329.  
  4330.       if (GET_CODE (temp) == REG && GET_MODE (temp) != mode)
  4331.         {
  4332.           temp = gen_rtx (SUBREG, mode, SAVE_EXPR_RTL (exp), 0);
  4333.           SUBREG_PROMOTED_VAR_P (temp) = 1;
  4334.           SUBREG_PROMOTED_UNSIGNED_P (temp) = unsignedp;
  4335.         }
  4336.  
  4337.       if (temp == const0_rtx)
  4338.         expand_expr (TREE_OPERAND (exp, 0), const0_rtx, VOIDmode, 0);
  4339.       else
  4340.         store_expr (TREE_OPERAND (exp, 0), temp, 0);
  4341.     }
  4342.  
  4343.       /* If the mode of SAVE_EXPR_RTL does not match that of the expression, it
  4344.      must be a promoted value.  We return a SUBREG of the wanted mode,
  4345.      but mark it so that we know that it was already extended. */
  4346.  
  4347.       if (GET_CODE (SAVE_EXPR_RTL (exp)) == REG
  4348.       && GET_MODE (SAVE_EXPR_RTL (exp)) != mode)
  4349.     {
  4350.       /* Compute the signedness and make the proper SUBREG.  */
  4351.       promote_mode (type, mode, &unsignedp, 0);
  4352.       temp = gen_rtx (SUBREG, mode, SAVE_EXPR_RTL (exp), 0);
  4353.       SUBREG_PROMOTED_VAR_P (temp) = 1;
  4354.       SUBREG_PROMOTED_UNSIGNED_P (temp) = unsignedp;
  4355.       return temp;
  4356.     }
  4357.  
  4358.       return SAVE_EXPR_RTL (exp);
  4359.  
  4360.     case PLACEHOLDER_EXPR:
  4361.       /* If there is an object on the head of the placeholder list,
  4362.      see if some object in it's references is of type TYPE.  For
  4363.      further information, see tree.def.  */
  4364.       if (placeholder_list)
  4365.     {
  4366.       tree object;
  4367.       tree old_list = placeholder_list;
  4368.  
  4369.       for (object = TREE_PURPOSE (placeholder_list);
  4370.            (TYPE_MAIN_VARIANT (TREE_TYPE (object))
  4371.         != TYPE_MAIN_VARIANT (type))
  4372.            && (TREE_CODE_CLASS (TREE_CODE (object)) == 'r'
  4373.            || TREE_CODE_CLASS (TREE_CODE (object)) == '1'
  4374.            || TREE_CODE_CLASS (TREE_CODE (object)) == '2'
  4375.            || TREE_CODE_CLASS (TREE_CODE (object)) == 'e');
  4376.            object = TREE_OPERAND (object, 0))
  4377.         ;
  4378.  
  4379.       if (object != 0
  4380.           && (TYPE_MAIN_VARIANT (TREE_TYPE (object))
  4381.           == TYPE_MAIN_VARIANT (type)))
  4382.         {
  4383.           /* Expand this object skipping the list entries before
  4384.          it was found in case it is also a PLACEHOLDER_EXPR.
  4385.          In that case, we want to translate it using subsequent
  4386.          entries.  */
  4387.           placeholder_list = TREE_CHAIN (placeholder_list);
  4388.           temp = expand_expr (object, original_target, tmode, modifier);
  4389.           placeholder_list = old_list;
  4390.           return temp;
  4391.         }
  4392.     }
  4393.  
  4394.       /* We can't find the object or there was a missing WITH_RECORD_EXPR.  */
  4395.       abort ();
  4396.  
  4397.     case WITH_RECORD_EXPR:
  4398.       /* Put the object on the placeholder list, expand our first operand,
  4399.      and pop the list.  */
  4400.       placeholder_list = tree_cons (TREE_OPERAND (exp, 1), NULL_TREE,
  4401.                     placeholder_list);
  4402.       target = expand_expr (TREE_OPERAND (exp, 0), original_target,
  4403.                 tmode, modifier);
  4404.       placeholder_list = TREE_CHAIN (placeholder_list);
  4405.       return target;
  4406.  
  4407.     case EXIT_EXPR:
  4408.       expand_exit_loop_if_false (NULL_PTR,
  4409.                  invert_truthvalue (TREE_OPERAND (exp, 0)));
  4410.       return const0_rtx;
  4411.  
  4412.     case LOOP_EXPR:
  4413.       push_temp_slots ();
  4414.       expand_start_loop (1);
  4415.       expand_expr_stmt (TREE_OPERAND (exp, 0));
  4416.       expand_end_loop ();
  4417.       pop_temp_slots ();
  4418.  
  4419.       return const0_rtx;
  4420.  
  4421.     case BIND_EXPR:
  4422.       {
  4423.     tree vars = TREE_OPERAND (exp, 0);
  4424.     int vars_need_expansion = 0;
  4425.  
  4426.     /* Need to open a binding contour here because
  4427.        if there are any cleanups they most be contained here.  */
  4428.     expand_start_bindings (0);
  4429.  
  4430.     /* Mark the corresponding BLOCK for output in its proper place.  */
  4431.     if (TREE_OPERAND (exp, 2) != 0
  4432.         && ! TREE_USED (TREE_OPERAND (exp, 2)))
  4433.       insert_block (TREE_OPERAND (exp, 2));
  4434.  
  4435.     /* If VARS have not yet been expanded, expand them now.  */
  4436.     while (vars)
  4437.       {
  4438.         if (DECL_RTL (vars) == 0)
  4439.           {
  4440.         vars_need_expansion = 1;
  4441.         expand_decl (vars);
  4442.           }
  4443.         expand_decl_init (vars);
  4444.         vars = TREE_CHAIN (vars);
  4445.       }
  4446.  
  4447.     temp = expand_expr (TREE_OPERAND (exp, 1), target, tmode, modifier);
  4448.  
  4449.     expand_end_bindings (TREE_OPERAND (exp, 0), 0, 0);
  4450.  
  4451.     return temp;
  4452.       }
  4453.  
  4454.     case RTL_EXPR:
  4455.       if (RTL_EXPR_SEQUENCE (exp) == const0_rtx)
  4456.     abort ();
  4457.       emit_insns (RTL_EXPR_SEQUENCE (exp));
  4458.       RTL_EXPR_SEQUENCE (exp) = const0_rtx;
  4459.       preserve_rtl_expr_result (RTL_EXPR_RTL (exp));
  4460.       free_temps_for_rtl_expr (exp);
  4461.       return RTL_EXPR_RTL (exp);
  4462.  
  4463.     case CONSTRUCTOR:
  4464.       /* If we don't need the result, just ensure we evaluate any
  4465.      subexpressions.  */
  4466.       if (ignore)
  4467.     {
  4468.       tree elt;
  4469.       for (elt = CONSTRUCTOR_ELTS (exp); elt; elt = TREE_CHAIN (elt))
  4470.         expand_expr (TREE_VALUE (elt), const0_rtx, VOIDmode, 0);
  4471.       return const0_rtx;
  4472.     }
  4473.  
  4474.       /* All elts simple constants => refer to a constant in memory.  But
  4475.      if this is a non-BLKmode mode, let it store a field at a time
  4476.      since that should make a CONST_INT or CONST_DOUBLE when we
  4477.      fold.  Likewise, if we have a target we can use, it is best to
  4478.      store directly into the target unless the type is large enough
  4479.      that memcpy will be used.  If we are making an initializer and
  4480.      all operands are constant, put it in memory as well.  */
  4481.       else if ((TREE_STATIC (exp)
  4482.         && ((mode == BLKmode
  4483.              && ! (target != 0 && safe_from_p (target, exp)))
  4484.             || TREE_ADDRESSABLE (exp)
  4485.             || (TREE_CODE (TYPE_SIZE (type)) == INTEGER_CST
  4486.             && (move_by_pieces_ninsns
  4487.                 (TREE_INT_CST_LOW (TYPE_SIZE (type))/BITS_PER_UNIT,
  4488.                  TYPE_ALIGN (type) / BITS_PER_UNIT)
  4489.                 > MOVE_RATIO))))
  4490.            || (modifier == EXPAND_INITIALIZER && TREE_CONSTANT (exp)))
  4491.     {
  4492.       rtx constructor = output_constant_def (exp);
  4493.       if (modifier != EXPAND_CONST_ADDRESS
  4494.           && modifier != EXPAND_INITIALIZER
  4495.           && modifier != EXPAND_SUM
  4496.           && (! memory_address_p (GET_MODE (constructor),
  4497.                       XEXP (constructor, 0))
  4498.           || (flag_force_addr
  4499.               && GET_CODE (XEXP (constructor, 0)) != REG)))
  4500.         constructor = change_address (constructor, VOIDmode,
  4501.                       XEXP (constructor, 0));
  4502.       return constructor;
  4503.     }
  4504.  
  4505.       else
  4506.     {
  4507.       if (target == 0 || ! safe_from_p (target, exp))
  4508.         {
  4509.           if (mode != BLKmode && ! TREE_ADDRESSABLE (exp))
  4510.         target = gen_reg_rtx (tmode != VOIDmode ? tmode : mode);
  4511.           else
  4512.         {
  4513.           target
  4514.             = assign_stack_temp (mode, int_size_in_bytes (type), 0);
  4515.           if (AGGREGATE_TYPE_P (type))
  4516.             MEM_IN_STRUCT_P (target) = 1;
  4517.         }
  4518.         }
  4519.       store_constructor (exp, target);
  4520.       return target;
  4521.     }
  4522.  
  4523.     case INDIRECT_REF:
  4524.       {
  4525.     tree exp1 = TREE_OPERAND (exp, 0);
  4526.     tree exp2;
  4527.  
  4528.     /* A SAVE_EXPR as the address in an INDIRECT_EXPR is generated
  4529.        for  *PTR += ANYTHING  where PTR is put inside the SAVE_EXPR.
  4530.        This code has the same general effect as simply doing
  4531.        expand_expr on the save expr, except that the expression PTR
  4532.        is computed for use as a memory address.  This means different
  4533.        code, suitable for indexing, may be generated.  */
  4534.     if (TREE_CODE (exp1) == SAVE_EXPR
  4535.         && SAVE_EXPR_RTL (exp1) == 0
  4536.         && TYPE_MODE (TREE_TYPE (exp1)) == ptr_mode)
  4537.       {
  4538.         temp = expand_expr (TREE_OPERAND (exp1, 0), NULL_RTX,
  4539.                 VOIDmode, EXPAND_SUM);
  4540.         op0 = memory_address (mode, temp);
  4541.         op0 = copy_all_regs (op0);
  4542.         SAVE_EXPR_RTL (exp1) = op0;
  4543.       }
  4544.     else
  4545.       {
  4546.         op0 = expand_expr (exp1, NULL_RTX, VOIDmode, EXPAND_SUM);
  4547.         op0 = memory_address (mode, op0);
  4548.       }
  4549.  
  4550.     temp = gen_rtx (MEM, mode, op0);
  4551.     /* If address was computed by addition,
  4552.        mark this as an element of an aggregate.  */
  4553.     if (TREE_CODE (TREE_OPERAND (exp, 0)) == PLUS_EXPR
  4554.         || (TREE_CODE (TREE_OPERAND (exp, 0)) == SAVE_EXPR
  4555.         && TREE_CODE (TREE_OPERAND (TREE_OPERAND (exp, 0), 0)) == PLUS_EXPR)
  4556.         || AGGREGATE_TYPE_P (TREE_TYPE (exp))
  4557.         || (TREE_CODE (exp1) == ADDR_EXPR
  4558.         && (exp2 = TREE_OPERAND (exp1, 0))
  4559.         && AGGREGATE_TYPE_P (TREE_TYPE (exp2))))
  4560.       MEM_IN_STRUCT_P (temp) = 1;
  4561.     MEM_VOLATILE_P (temp) = TREE_THIS_VOLATILE (exp) | flag_volatile;
  4562.  
  4563.     /* It is incorrect to set RTX_UNCHANGING_P from TREE_READONLY
  4564.        here, because, in C and C++, the fact that a location is accessed
  4565.        through a pointer to const does not mean that the value there can
  4566.        never change.  Languages where it can never change should
  4567.        also set TREE_STATIC.  */
  4568.     RTX_UNCHANGING_P (temp) = TREE_READONLY (exp) | TREE_STATIC (exp);
  4569.     return temp;
  4570.       }
  4571.  
  4572.     case ARRAY_REF:
  4573.       if (TREE_CODE (TREE_TYPE (TREE_OPERAND (exp, 0))) != ARRAY_TYPE)
  4574.     abort ();
  4575.  
  4576.       {
  4577.     tree array = TREE_OPERAND (exp, 0);
  4578.     tree domain = TYPE_DOMAIN (TREE_TYPE (array));
  4579.     tree low_bound = domain ? TYPE_MIN_VALUE (domain) : integer_zero_node;
  4580.     tree index = TREE_OPERAND (exp, 1);
  4581.     tree index_type = TREE_TYPE (index);
  4582.     int i;
  4583.  
  4584.     if (TREE_CODE (low_bound) != INTEGER_CST
  4585.         && contains_placeholder_p (low_bound))
  4586.       low_bound = build (WITH_RECORD_EXPR, sizetype, low_bound, exp);
  4587.  
  4588.     /* Optimize the special-case of a zero lower bound.
  4589.  
  4590.        We convert the low_bound to sizetype to avoid some problems
  4591.        with constant folding.  (E.g. suppose the lower bound is 1,
  4592.        and its mode is QI.  Without the conversion,  (ARRAY
  4593.        +(INDEX-(unsigned char)1)) becomes ((ARRAY+(-(unsigned char)1))
  4594.        +INDEX), which becomes (ARRAY+255+INDEX).  Oops!)
  4595.  
  4596.        But sizetype isn't quite right either (especially if
  4597.        the lowbound is negative).  FIXME */
  4598.  
  4599.     if (! integer_zerop (low_bound))
  4600.       index = fold (build (MINUS_EXPR, index_type, index,
  4601.                    convert (sizetype, low_bound)));
  4602.  
  4603.     if ((TREE_CODE (index) != INTEGER_CST
  4604.          || TREE_CODE (TYPE_SIZE (type)) != INTEGER_CST)
  4605.         && (! SLOW_UNALIGNED_ACCESS || ! get_inner_unaligned_p (exp)))
  4606.       {
  4607.         /* Nonconstant array index or nonconstant element size, and
  4608.            not an array in an unaligned (packed) structure field.
  4609.            Generate the tree for *(&array+index) and expand that,
  4610.            except do it in a language-independent way
  4611.            and don't complain about non-lvalue arrays.
  4612.            `mark_addressable' should already have been called
  4613.            for any array for which this case will be reached.  */
  4614.  
  4615.         /* Don't forget the const or volatile flag from the array
  4616.            element. */
  4617.         tree variant_type = build_type_variant (type,
  4618.                             TREE_READONLY (exp),
  4619.                             TREE_THIS_VOLATILE (exp));
  4620.         tree array_adr = build1 (ADDR_EXPR,
  4621.                      build_pointer_type (variant_type), array);
  4622.         tree elt;
  4623.         tree size = size_in_bytes (type);
  4624.  
  4625.         /* Convert the integer argument to a type the same size as a
  4626.            pointer so the multiply won't overflow spuriously.  */
  4627.         if (TYPE_PRECISION (index_type) != POINTER_SIZE)
  4628.           index = convert (type_for_size (POINTER_SIZE, 0), index);
  4629.  
  4630.         if (TREE_CODE (size) != INTEGER_CST
  4631.         && contains_placeholder_p (size))
  4632.           size = build (WITH_RECORD_EXPR, sizetype, size, exp);
  4633.  
  4634.         /* Don't think the address has side effects
  4635.            just because the array does.
  4636.            (In some cases the address might have side effects,
  4637.            and we fail to record that fact here.  However, it should not
  4638.            matter, since expand_expr should not care.)  */
  4639.         TREE_SIDE_EFFECTS (array_adr) = 0;
  4640.  
  4641.         elt = build1 (INDIRECT_REF, type,
  4642.               fold (build (PLUS_EXPR,
  4643.                        TYPE_POINTER_TO (variant_type),
  4644.                        array_adr,
  4645.                        fold (build (MULT_EXPR,
  4646.                             TYPE_POINTER_TO (variant_type),
  4647.                             index, size)))));
  4648.  
  4649.         /* Volatility, etc., of new expression is same as old
  4650.            expression.  */
  4651.         TREE_SIDE_EFFECTS (elt) = TREE_SIDE_EFFECTS (exp);
  4652.         TREE_THIS_VOLATILE (elt) = TREE_THIS_VOLATILE (exp);
  4653.         TREE_READONLY (elt) = TREE_READONLY (exp);
  4654.  
  4655.         return expand_expr (elt, target, tmode, modifier);
  4656.       }
  4657.  
  4658.     /* Fold an expression like: "foo"[2].
  4659.        This is not done in fold so it won't happen inside &.
  4660.        Don't fold if this is for wide characters since it's too
  4661.        difficult to do correctly and this is a very rare case.  */
  4662.  
  4663.     if (TREE_CODE (array) == STRING_CST
  4664.         && TREE_CODE (index) == INTEGER_CST
  4665.         && !TREE_INT_CST_HIGH (index)
  4666.         && (i = TREE_INT_CST_LOW (index)) < TREE_STRING_LENGTH (array)
  4667.         && GET_MODE_CLASS (mode) == MODE_INT
  4668.         && GET_MODE_SIZE (mode) == 1)
  4669.       return GEN_INT (TREE_STRING_POINTER (array)[i]);
  4670.  
  4671.     /* If this is a constant index into a constant array,
  4672.        just get the value from the array.  Handle both the cases when
  4673.        we have an explicit constructor and when our operand is a variable
  4674.        that was declared const.  */
  4675.  
  4676.     if (TREE_CODE (array) == CONSTRUCTOR && ! TREE_SIDE_EFFECTS (array))
  4677.       {
  4678.         if (TREE_CODE (index) == INTEGER_CST
  4679.         && TREE_INT_CST_HIGH (index) == 0)
  4680.           {
  4681.         tree elem = CONSTRUCTOR_ELTS (TREE_OPERAND (exp, 0));
  4682.  
  4683.         i = TREE_INT_CST_LOW (index);
  4684.         while (elem && i--)
  4685.           elem = TREE_CHAIN (elem);
  4686.         if (elem)
  4687.           return expand_expr (fold (TREE_VALUE (elem)), target,
  4688.                       tmode, modifier);
  4689.           }
  4690.       }
  4691.       
  4692.     else if (optimize >= 1
  4693.          && TREE_READONLY (array) && ! TREE_SIDE_EFFECTS (array)
  4694.          && TREE_CODE (array) == VAR_DECL && DECL_INITIAL (array)
  4695.          && TREE_CODE (DECL_INITIAL (array)) != ERROR_MARK)
  4696.       {
  4697.         if (TREE_CODE (index) == INTEGER_CST
  4698.         && TREE_INT_CST_HIGH (index) == 0)
  4699.           {
  4700.         tree init = DECL_INITIAL (array);
  4701.  
  4702.         i = TREE_INT_CST_LOW (index);
  4703.         if (TREE_CODE (init) == CONSTRUCTOR)
  4704.           {
  4705.             tree elem = CONSTRUCTOR_ELTS (init);
  4706.  
  4707.             while (elem
  4708.                && !tree_int_cst_equal (TREE_PURPOSE (elem), index))
  4709.               elem = TREE_CHAIN (elem);
  4710.             if (elem)
  4711.               return expand_expr (fold (TREE_VALUE (elem)), target,
  4712.                       tmode, modifier);
  4713.           }
  4714.         else if (TREE_CODE (init) == STRING_CST
  4715.              && i < TREE_STRING_LENGTH (init))
  4716.           return GEN_INT (TREE_STRING_POINTER (init)[i]);
  4717.           }
  4718.       }
  4719.       }
  4720.  
  4721.       /* Treat array-ref with constant index as a component-ref.  */
  4722.  
  4723.     case COMPONENT_REF:
  4724.     case BIT_FIELD_REF:
  4725.       /* If the operand is a CONSTRUCTOR, we can just extract the
  4726.      appropriate field if it is present.  Don't do this if we have
  4727.      already written the data since we want to refer to that copy
  4728.      and varasm.c assumes that's what we'll do.  */
  4729.       if (code != ARRAY_REF
  4730.       && TREE_CODE (TREE_OPERAND (exp, 0)) == CONSTRUCTOR
  4731.       && TREE_CST_RTL (TREE_OPERAND (exp, 0)) == 0)
  4732.     {
  4733.       tree elt;
  4734.  
  4735.       for (elt = CONSTRUCTOR_ELTS (TREE_OPERAND (exp, 0)); elt;
  4736.            elt = TREE_CHAIN (elt))
  4737.         if (TREE_PURPOSE (elt) == TREE_OPERAND (exp, 1))
  4738.           return expand_expr (TREE_VALUE (elt), target, tmode, modifier);
  4739.     }
  4740.  
  4741.       {
  4742.     enum machine_mode mode1;
  4743.     int bitsize;
  4744.     int bitpos;
  4745.     tree offset;
  4746.     int volatilep = 0;
  4747.     tree tem = get_inner_reference (exp, &bitsize, &bitpos, &offset,
  4748.                     &mode1, &unsignedp, &volatilep);
  4749.     int alignment;
  4750.  
  4751.     /* If we got back the original object, something is wrong.  Perhaps
  4752.        we are evaluating an expression too early.  In any event, don't
  4753.        infinitely recurse.  */
  4754.     if (tem == exp)
  4755.       abort ();
  4756.  
  4757.     /* In some cases, we will be offsetting OP0's address by a constant.
  4758.        So get it as a sum, if possible.  If we will be using it
  4759.        directly in an insn, we validate it.  */
  4760.     op0 = expand_expr (tem, NULL_RTX, VOIDmode, EXPAND_SUM);
  4761.  
  4762.     /* If this is a constant, put it into a register if it is a
  4763.        legitimate constant and memory if it isn't.  */
  4764.     if (CONSTANT_P (op0))
  4765.       {
  4766.         enum machine_mode mode = TYPE_MODE (TREE_TYPE (tem));
  4767.         if (mode != BLKmode && LEGITIMATE_CONSTANT_P (op0))
  4768.           op0 = force_reg (mode, op0);
  4769.         else
  4770.           op0 = validize_mem (force_const_mem (mode, op0));
  4771.       }
  4772.  
  4773.     alignment = TYPE_ALIGN (TREE_TYPE (tem)) / BITS_PER_UNIT;
  4774.     if (offset != 0)
  4775.       {
  4776.         rtx offset_rtx = expand_expr (offset, NULL_RTX, VOIDmode, 0);
  4777.  
  4778.         if (GET_CODE (op0) != MEM)
  4779.           abort ();
  4780.         op0 = change_address (op0, VOIDmode,
  4781.                   gen_rtx (PLUS, ptr_mode, XEXP (op0, 0),
  4782.                        force_reg (ptr_mode, offset_rtx)));
  4783.       /* If we have a variable offset, the known alignment
  4784.          is only that of the innermost structure containing the field.
  4785.          (Actually, we could sometimes do better by using the
  4786.          size of an element of the innermost array, but no need.)  */
  4787.       if (TREE_CODE (exp) == COMPONENT_REF
  4788.           || TREE_CODE (exp) == BIT_FIELD_REF)
  4789.         alignment = (TYPE_ALIGN (TREE_TYPE (TREE_OPERAND (exp, 0)))
  4790.              / BITS_PER_UNIT);
  4791.       }
  4792.  
  4793.     /* Don't forget about volatility even if this is a bitfield.  */
  4794.     if (GET_CODE (op0) == MEM && volatilep && ! MEM_VOLATILE_P (op0))
  4795.       {
  4796.         op0 = copy_rtx (op0);
  4797.         MEM_VOLATILE_P (op0) = 1;
  4798.       }
  4799.  
  4800.     /* In cases where an aligned union has an unaligned object
  4801.        as a field, we might be extracting a BLKmode value from
  4802.        an integer-mode (e.g., SImode) object.  Handle this case
  4803.        by doing the extract into an object as wide as the field
  4804.        (which we know to be the width of a basic mode), then
  4805.        storing into memory, and changing the mode to BLKmode.  */
  4806.     if (mode1 == VOIDmode
  4807.         || GET_CODE (op0) == REG || GET_CODE (op0) == SUBREG
  4808.         || (modifier != EXPAND_CONST_ADDRESS
  4809.         && modifier != EXPAND_SUM
  4810.         && modifier != EXPAND_INITIALIZER
  4811.         && ((mode1 != BLKmode && ! direct_load[(int) mode1])
  4812.             /* If the field isn't aligned enough to fetch as a memref,
  4813.                fetch it as a bit field.  */
  4814.             || (SLOW_UNALIGNED_ACCESS
  4815.             && ((TYPE_ALIGN (TREE_TYPE (tem)) < GET_MODE_ALIGNMENT (mode))
  4816.                 || (bitpos % GET_MODE_ALIGNMENT (mode) != 0))))))
  4817.       {
  4818.         enum machine_mode ext_mode = mode;
  4819.  
  4820.         if (ext_mode == BLKmode)
  4821.           ext_mode = mode_for_size (bitsize, MODE_INT, 1);
  4822.  
  4823.         if (ext_mode == BLKmode)
  4824.           abort ();
  4825.  
  4826.         op0 = extract_bit_field (validize_mem (op0), bitsize, bitpos,
  4827.                      unsignedp, target, ext_mode, ext_mode,
  4828.                      alignment,
  4829.                      int_size_in_bytes (TREE_TYPE (tem)));
  4830.         if (mode == BLKmode)
  4831.           {
  4832.         rtx new = assign_stack_temp (ext_mode,
  4833.                          bitsize / BITS_PER_UNIT, 0);
  4834.  
  4835.         emit_move_insn (new, op0);
  4836.         op0 = copy_rtx (new);
  4837.         PUT_MODE (op0, BLKmode);
  4838.         MEM_IN_STRUCT_P (op0) = 1;
  4839.           }
  4840.  
  4841.         return op0;
  4842.       }
  4843.  
  4844.     /* Get a reference to just this component.  */
  4845.     if (modifier == EXPAND_CONST_ADDRESS
  4846.         || modifier == EXPAND_SUM || modifier == EXPAND_INITIALIZER)
  4847.       op0 = gen_rtx (MEM, mode1, plus_constant (XEXP (op0, 0),
  4848.                             (bitpos / BITS_PER_UNIT)));
  4849.     else
  4850.       op0 = change_address (op0, mode1,
  4851.                 plus_constant (XEXP (op0, 0),
  4852.                            (bitpos / BITS_PER_UNIT)));
  4853.     MEM_IN_STRUCT_P (op0) = 1;
  4854.     MEM_VOLATILE_P (op0) |= volatilep;
  4855.     if (mode == mode1 || mode1 == BLKmode || mode1 == tmode)
  4856.       return op0;
  4857.     if (target == 0)
  4858.       target = gen_reg_rtx (tmode != VOIDmode ? tmode : mode);
  4859.     convert_move (target, op0, unsignedp);
  4860.     return target;
  4861.       }
  4862.  
  4863.     case OFFSET_REF:
  4864.       {
  4865.     tree base = build1 (ADDR_EXPR, type, TREE_OPERAND (exp, 0));
  4866.     tree addr = build (PLUS_EXPR, type, base, TREE_OPERAND (exp, 1));
  4867.     op0 = expand_expr (addr, NULL_RTX, VOIDmode, EXPAND_SUM);
  4868.     temp = gen_rtx (MEM, mode, memory_address (mode, op0));
  4869.     MEM_IN_STRUCT_P (temp) = 1;
  4870.     MEM_VOLATILE_P (temp) = TREE_THIS_VOLATILE (exp);
  4871. #if 0 /* It is incorrect to set RTX_UNCHANGING_P here, because the fact that
  4872.      a location is accessed through a pointer to const does not mean
  4873.      that the value there can never change.  */
  4874.     RTX_UNCHANGING_P (temp) = TREE_READONLY (exp);
  4875. #endif
  4876.     return temp;
  4877.       }
  4878.  
  4879.       /* Intended for a reference to a buffer of a file-object in Pascal.
  4880.      But it's not certain that a special tree code will really be
  4881.      necessary for these.  INDIRECT_REF might work for them.  */
  4882.     case BUFFER_REF:
  4883.       abort ();
  4884.  
  4885.     case IN_EXPR:
  4886.       {
  4887.     /* Pascal set IN expression.
  4888.  
  4889.        Algorithm:
  4890.            rlo       = set_low - (set_low%bits_per_word);
  4891.            the_word  = set [ (index - rlo)/bits_per_word ];
  4892.            bit_index = index % bits_per_word;
  4893.            bitmask   = 1 << bit_index;
  4894.            return !!(the_word & bitmask);  */
  4895.  
  4896.     tree set = TREE_OPERAND (exp, 0);
  4897.     tree index = TREE_OPERAND (exp, 1);
  4898.     int iunsignedp = TREE_UNSIGNED (TREE_TYPE (index));
  4899.     tree set_type = TREE_TYPE (set);
  4900.     tree set_low_bound = TYPE_MIN_VALUE (TYPE_DOMAIN (set_type));
  4901.     tree set_high_bound = TYPE_MAX_VALUE (TYPE_DOMAIN (set_type));
  4902.     rtx index_val = expand_expr (index, 0, VOIDmode, 0);
  4903.     rtx lo_r = expand_expr (set_low_bound, 0, VOIDmode, 0);
  4904.     rtx hi_r = expand_expr (set_high_bound, 0, VOIDmode, 0);
  4905.     rtx setval = expand_expr (set, 0, VOIDmode, 0);
  4906.     rtx setaddr = XEXP (setval, 0);
  4907.     enum machine_mode index_mode = TYPE_MODE (TREE_TYPE (index));
  4908.     rtx rlow;
  4909.     rtx diff, quo, rem, addr, bit, result;
  4910.  
  4911.     preexpand_calls (exp);
  4912.  
  4913.     /* If domain is empty, answer is no.  Likewise if index is constant
  4914.        and out of bounds.  */
  4915.     if ((TREE_CODE (set_high_bound) == INTEGER_CST
  4916.          && TREE_CODE (set_low_bound) == INTEGER_CST
  4917.          && tree_int_cst_lt (set_high_bound, set_low_bound)
  4918.          || (TREE_CODE (index) == INTEGER_CST
  4919.          && TREE_CODE (set_low_bound) == INTEGER_CST
  4920.          && tree_int_cst_lt (index, set_low_bound))
  4921.          || (TREE_CODE (set_high_bound) == INTEGER_CST
  4922.          && TREE_CODE (index) == INTEGER_CST
  4923.          && tree_int_cst_lt (set_high_bound, index))))
  4924.       return const0_rtx;
  4925.  
  4926.     if (target == 0)
  4927.       target = gen_reg_rtx (tmode != VOIDmode ? tmode : mode);
  4928.  
  4929.     /* If we get here, we have to generate the code for both cases
  4930.        (in range and out of range).  */
  4931.  
  4932.     op0 = gen_label_rtx ();
  4933.     op1 = gen_label_rtx ();
  4934.  
  4935.     if (! (GET_CODE (index_val) == CONST_INT
  4936.            && GET_CODE (lo_r) == CONST_INT))
  4937.       {
  4938.         emit_cmp_insn (index_val, lo_r, LT, NULL_RTX,
  4939.                GET_MODE (index_val), iunsignedp, 0);
  4940.         emit_jump_insn (gen_blt (op1));
  4941.       }
  4942.  
  4943.     if (! (GET_CODE (index_val) == CONST_INT
  4944.            && GET_CODE (hi_r) == CONST_INT))
  4945.       {
  4946.         emit_cmp_insn (index_val, hi_r, GT, NULL_RTX,
  4947.                GET_MODE (index_val), iunsignedp, 0);
  4948.         emit_jump_insn (gen_bgt (op1));
  4949.       }
  4950.  
  4951.     /* Calculate the element number of bit zero in the first word
  4952.        of the set.  */
  4953.     if (GET_CODE (lo_r) == CONST_INT)
  4954.       rlow = GEN_INT (INTVAL (lo_r)
  4955.               & ~ ((HOST_WIDE_INT) 1 << BITS_PER_UNIT));
  4956.     else
  4957.       rlow = expand_binop (index_mode, and_optab, lo_r,
  4958.                    GEN_INT (~((HOST_WIDE_INT) 1 << BITS_PER_UNIT)),
  4959.                    NULL_RTX, iunsignedp, OPTAB_LIB_WIDEN);
  4960.  
  4961.     diff = expand_binop (index_mode, sub_optab, index_val, rlow,
  4962.                  NULL_RTX, iunsignedp, OPTAB_LIB_WIDEN);
  4963.  
  4964.     quo = expand_divmod (0, TRUNC_DIV_EXPR, index_mode, diff,
  4965.                  GEN_INT (BITS_PER_UNIT), NULL_RTX, iunsignedp);
  4966.     rem = expand_divmod (1, TRUNC_MOD_EXPR, index_mode, index_val,
  4967.                  GEN_INT (BITS_PER_UNIT), NULL_RTX, iunsignedp);
  4968.  
  4969.     addr = memory_address (byte_mode,
  4970.                    expand_binop (index_mode, add_optab, diff,
  4971.                          setaddr, NULL_RTX, iunsignedp,
  4972.                          OPTAB_LIB_WIDEN));
  4973.  
  4974.     /* Extract the bit we want to examine */
  4975.     bit = expand_shift (RSHIFT_EXPR, byte_mode,
  4976.                 gen_rtx (MEM, byte_mode, addr),
  4977.                 make_tree (TREE_TYPE (index), rem),
  4978.                 NULL_RTX, 1);
  4979.     result = expand_binop (byte_mode, and_optab, bit, const1_rtx,
  4980.                    GET_MODE (target) == byte_mode ? target : 0,
  4981.                    1, OPTAB_LIB_WIDEN);
  4982.  
  4983.     if (result != target)
  4984.       convert_move (target, result, 1);
  4985.  
  4986.     /* Output the code to handle the out-of-range case.  */
  4987.     emit_jump (op0);
  4988.     emit_label (op1);
  4989.     emit_move_insn (target, const0_rtx);
  4990.     emit_label (op0);
  4991.     return target;
  4992.       }
  4993.  
  4994.     case WITH_CLEANUP_EXPR:
  4995.       if (RTL_EXPR_RTL (exp) == 0)
  4996.     {
  4997.       RTL_EXPR_RTL (exp)
  4998.         = expand_expr (TREE_OPERAND (exp, 0), target, tmode, modifier);
  4999.       cleanups_this_call
  5000.         = tree_cons (NULL_TREE, TREE_OPERAND (exp, 2), cleanups_this_call);
  5001.       /* That's it for this cleanup.  */
  5002.       TREE_OPERAND (exp, 2) = 0;
  5003.       (*interim_eh_hook) (NULL_TREE);
  5004.     }
  5005.       return RTL_EXPR_RTL (exp);
  5006.  
  5007.     case CLEANUP_POINT_EXPR:
  5008.       {
  5009.     extern int temp_slot_level;
  5010.     tree old_cleanups = cleanups_this_call;
  5011.     int old_temp_level = target_temp_slot_level;
  5012.     push_temp_slots ();
  5013.     target_temp_slot_level = temp_slot_level;
  5014.     op0 = expand_expr (TREE_OPERAND (exp, 0), target, tmode, modifier);
  5015.     /* If we're going to use this value, load it up now.  */
  5016.     if (! ignore)
  5017.       op0 = force_not_mem (op0);
  5018.     expand_cleanups_to (old_cleanups);
  5019.     preserve_temp_slots (op0);
  5020.     free_temp_slots ();
  5021.     pop_temp_slots ();
  5022.     target_temp_slot_level = old_temp_level;
  5023.       }
  5024.       return op0;
  5025.  
  5026.     case CALL_EXPR:
  5027.       /* Check for a built-in function.  */
  5028.       if (TREE_CODE (TREE_OPERAND (exp, 0)) == ADDR_EXPR
  5029.       && (TREE_CODE (TREE_OPERAND (TREE_OPERAND (exp, 0), 0))
  5030.           == FUNCTION_DECL)
  5031.       && DECL_BUILT_IN (TREE_OPERAND (TREE_OPERAND (exp, 0), 0)))
  5032.     return expand_builtin (exp, target, subtarget, tmode, ignore);
  5033.  
  5034.       /* If this call was expanded already by preexpand_calls,
  5035.      just return the result we got.  */
  5036.       if (CALL_EXPR_RTL (exp) != 0)
  5037.     return CALL_EXPR_RTL (exp);
  5038.  
  5039.       return expand_call (exp, target, ignore);
  5040.  
  5041.     case NON_LVALUE_EXPR:
  5042.     case NOP_EXPR:
  5043.     case CONVERT_EXPR:
  5044.     case REFERENCE_EXPR:
  5045.       if (TREE_CODE (type) == UNION_TYPE)
  5046.     {
  5047.       tree valtype = TREE_TYPE (TREE_OPERAND (exp, 0));
  5048.       if (target == 0)
  5049.         {
  5050.           if (mode == BLKmode)
  5051.         {
  5052.           if (TYPE_SIZE (type) == 0
  5053.               || TREE_CODE (TYPE_SIZE (type)) != INTEGER_CST)
  5054.             abort ();
  5055.           target = assign_stack_temp (BLKmode,
  5056.                           (TREE_INT_CST_LOW (TYPE_SIZE (type))
  5057.                            + BITS_PER_UNIT - 1)
  5058.                           / BITS_PER_UNIT, 0);
  5059.           MEM_IN_STRUCT_P (target) = AGGREGATE_TYPE_P (type);
  5060.         }
  5061.           else
  5062.         target = gen_reg_rtx (tmode != VOIDmode ? tmode : mode);
  5063.         }
  5064.  
  5065.       if (GET_CODE (target) == MEM)
  5066.         /* Store data into beginning of memory target.  */
  5067.         store_expr (TREE_OPERAND (exp, 0),
  5068.             change_address (target, TYPE_MODE (valtype), 0), 0);
  5069.  
  5070.       else if (GET_CODE (target) == REG)
  5071.         /* Store this field into a union of the proper type.  */
  5072.         store_field (target, GET_MODE_BITSIZE (TYPE_MODE (valtype)), 0,
  5073.              TYPE_MODE (valtype), TREE_OPERAND (exp, 0),
  5074.              VOIDmode, 0, 1,
  5075.              int_size_in_bytes (TREE_TYPE (TREE_OPERAND (exp, 0))));
  5076.       else
  5077.         abort ();
  5078.  
  5079.       /* Return the entire union.  */
  5080.       return target;
  5081.     }
  5082.  
  5083.       if (mode == TYPE_MODE (TREE_TYPE (TREE_OPERAND (exp, 0))))
  5084.     {
  5085.       op0 = expand_expr (TREE_OPERAND (exp, 0), target, VOIDmode,
  5086.                  modifier);
  5087.  
  5088.       /* If the signedness of the conversion differs and OP0 is
  5089.          a promoted SUBREG, clear that indication since we now
  5090.          have to do the proper extension.  */
  5091.       if (TREE_UNSIGNED (TREE_TYPE (TREE_OPERAND (exp, 0))) != unsignedp
  5092.           && GET_CODE (op0) == SUBREG)
  5093.         SUBREG_PROMOTED_VAR_P (op0) = 0;
  5094.  
  5095.       return op0;
  5096.     }
  5097.  
  5098.       op0 = expand_expr (TREE_OPERAND (exp, 0), NULL_RTX, mode, 0);
  5099.       if (GET_MODE (op0) == mode)
  5100.     return op0;
  5101.  
  5102.       /* If OP0 is a constant, just convert it into the proper mode.  */
  5103.       if (CONSTANT_P (op0))
  5104.     return
  5105.       convert_modes (mode, TYPE_MODE (TREE_TYPE (TREE_OPERAND (exp, 0))),
  5106.              op0, TREE_UNSIGNED (TREE_TYPE (TREE_OPERAND (exp, 0))));
  5107.  
  5108.       if (modifier == EXPAND_INITIALIZER)
  5109.     return gen_rtx (unsignedp ? ZERO_EXTEND : SIGN_EXTEND, mode, op0);
  5110.  
  5111.       if (flag_force_mem && GET_CODE (op0) == MEM)
  5112.     op0 = copy_to_reg (op0);
  5113.  
  5114.       if (target == 0)
  5115.     return
  5116.       convert_to_mode (mode, op0,
  5117.                TREE_UNSIGNED (TREE_TYPE (TREE_OPERAND (exp, 0))));
  5118.       else
  5119.     convert_move (target, op0,
  5120.               TREE_UNSIGNED (TREE_TYPE (TREE_OPERAND (exp, 0))));
  5121.       return target;
  5122.  
  5123.     case PLUS_EXPR:
  5124.       /* We come here from MINUS_EXPR when the second operand is a constant. */
  5125.     plus_expr:
  5126.       this_optab = add_optab;
  5127.  
  5128.       /* If we are adding a constant, an RTL_EXPR that is sp, fp, or ap, and
  5129.      something else, make sure we add the register to the constant and
  5130.      then to the other thing.  This case can occur during strength
  5131.      reduction and doing it this way will produce better code if the
  5132.      frame pointer or argument pointer is eliminated.
  5133.  
  5134.      fold-const.c will ensure that the constant is always in the inner
  5135.      PLUS_EXPR, so the only case we need to do anything about is if
  5136.      sp, ap, or fp is our second argument, in which case we must swap
  5137.      the innermost first argument and our second argument.  */
  5138.  
  5139.       if (TREE_CODE (TREE_OPERAND (exp, 0)) == PLUS_EXPR
  5140.       && TREE_CODE (TREE_OPERAND (TREE_OPERAND (exp, 0), 1)) == INTEGER_CST
  5141.       && TREE_CODE (TREE_OPERAND (exp, 1)) == RTL_EXPR
  5142.       && (RTL_EXPR_RTL (TREE_OPERAND (exp, 1)) == frame_pointer_rtx
  5143.           || RTL_EXPR_RTL (TREE_OPERAND (exp, 1)) == stack_pointer_rtx
  5144.           || RTL_EXPR_RTL (TREE_OPERAND (exp, 1)) == arg_pointer_rtx))
  5145.     {
  5146.       tree t = TREE_OPERAND (exp, 1);
  5147.  
  5148.       TREE_OPERAND (exp, 1) = TREE_OPERAND (TREE_OPERAND (exp, 0), 0);
  5149.       TREE_OPERAND (TREE_OPERAND (exp, 0), 0) = t;
  5150.     }
  5151.  
  5152.       /* If the result is to be ptr_mode and we are adding an integer to
  5153.      something, we might be forming a constant.  So try to use
  5154.      plus_constant.  If it produces a sum and we can't accept it,
  5155.      use force_operand.  This allows P = &ARR[const] to generate
  5156.      efficient code on machines where a SYMBOL_REF is not a valid
  5157.      address.
  5158.  
  5159.      If this is an EXPAND_SUM call, always return the sum.  */
  5160.       if (modifier == EXPAND_SUM || modifier == EXPAND_INITIALIZER
  5161.       || mode == ptr_mode)
  5162.     {
  5163.       if (TREE_CODE (TREE_OPERAND (exp, 0)) == INTEGER_CST
  5164.           && GET_MODE_BITSIZE (mode) <= HOST_BITS_PER_WIDE_INT
  5165.           && TREE_CONSTANT (TREE_OPERAND (exp, 1)))
  5166.         {
  5167.           op1 = expand_expr (TREE_OPERAND (exp, 1), subtarget, VOIDmode,
  5168.                  EXPAND_SUM);
  5169.           op1 = plus_constant (op1, TREE_INT_CST_LOW (TREE_OPERAND (exp, 0)));
  5170.           if (modifier != EXPAND_SUM && modifier != EXPAND_INITIALIZER)
  5171.         op1 = force_operand (op1, target);
  5172.           return op1;
  5173.         }
  5174.  
  5175.       else if (TREE_CODE (TREE_OPERAND (exp, 1)) == INTEGER_CST
  5176.            && GET_MODE_BITSIZE (mode) <= HOST_BITS_PER_INT
  5177.            && TREE_CONSTANT (TREE_OPERAND (exp, 0)))
  5178.         {
  5179.           op0 = expand_expr (TREE_OPERAND (exp, 0), subtarget, VOIDmode,
  5180.                  EXPAND_SUM);
  5181.           if (! CONSTANT_P (op0))
  5182.         {
  5183.           op1 = expand_expr (TREE_OPERAND (exp, 1), NULL_RTX,
  5184.                      VOIDmode, modifier);
  5185.           /* Don't go to both_summands if modifier
  5186.              says it's not right to return a PLUS.  */
  5187.           if (modifier != EXPAND_SUM && modifier != EXPAND_INITIALIZER)
  5188.             goto binop2;
  5189.           goto both_summands;
  5190.         }
  5191.           op0 = plus_constant (op0, TREE_INT_CST_LOW (TREE_OPERAND (exp, 1)));
  5192.           if (modifier != EXPAND_SUM && modifier != EXPAND_INITIALIZER)
  5193.         op0 = force_operand (op0, target);
  5194.           return op0;
  5195.         }
  5196.     }
  5197.  
  5198.       /* No sense saving up arithmetic to be done
  5199.      if it's all in the wrong mode to form part of an address.
  5200.      And force_operand won't know whether to sign-extend or
  5201.      zero-extend.  */
  5202.       if ((modifier != EXPAND_SUM && modifier != EXPAND_INITIALIZER)
  5203.       || mode != ptr_mode)
  5204.     goto binop;
  5205.  
  5206.       preexpand_calls (exp);
  5207.       if (! safe_from_p (subtarget, TREE_OPERAND (exp, 1)))
  5208.     subtarget = 0;
  5209.  
  5210.       op0 = expand_expr (TREE_OPERAND (exp, 0), subtarget, VOIDmode, modifier);
  5211.       op1 = expand_expr (TREE_OPERAND (exp, 1), NULL_RTX, VOIDmode, modifier);
  5212.  
  5213.     both_summands:
  5214.       /* Make sure any term that's a sum with a constant comes last.  */
  5215.       if (GET_CODE (op0) == PLUS
  5216.       && CONSTANT_P (XEXP (op0, 1)))
  5217.     {
  5218.       temp = op0;
  5219.       op0 = op1;
  5220.       op1 = temp;
  5221.     }
  5222.       /* If adding to a sum including a constant,
  5223.      associate it to put the constant outside.  */
  5224.       if (GET_CODE (op1) == PLUS
  5225.       && CONSTANT_P (XEXP (op1, 1)))
  5226.     {
  5227.       rtx constant_term = const0_rtx;
  5228.  
  5229.       temp = simplify_binary_operation (PLUS, mode, XEXP (op1, 0), op0);
  5230.       if (temp != 0)
  5231.         op0 = temp;
  5232.       /* Ensure that MULT comes first if there is one.  */
  5233.       else if (GET_CODE (op0) == MULT)
  5234.         op0 = gen_rtx (PLUS, mode, op0, XEXP (op1, 0));
  5235.       else
  5236.         op0 = gen_rtx (PLUS, mode, XEXP (op1, 0), op0);
  5237.  
  5238.       /* Let's also eliminate constants from op0 if possible.  */
  5239.       op0 = eliminate_constant_term (op0, &constant_term);
  5240.  
  5241.       /* CONSTANT_TERM and XEXP (op1, 1) are known to be constant, so
  5242.          their sum should be a constant.  Form it into OP1, since the 
  5243.          result we want will then be OP0 + OP1.  */
  5244.  
  5245.       temp = simplify_binary_operation (PLUS, mode, constant_term,
  5246.                         XEXP (op1, 1));
  5247.       if (temp != 0)
  5248.         op1 = temp;
  5249.       else
  5250.         op1 = gen_rtx (PLUS, mode, constant_term, XEXP (op1, 1));
  5251.     }
  5252.  
  5253.       /* Put a constant term last and put a multiplication first.  */
  5254.       if (CONSTANT_P (op0) || GET_CODE (op1) == MULT)
  5255.     temp = op1, op1 = op0, op0 = temp;
  5256.  
  5257.       temp = simplify_binary_operation (PLUS, mode, op0, op1);
  5258.       return temp ? temp : gen_rtx (PLUS, mode, op0, op1);
  5259.  
  5260.     case MINUS_EXPR:
  5261.       /* For initializers, we are allowed to return a MINUS of two
  5262.      symbolic constants.  Here we handle all cases when both operands
  5263.      are constant.  */
  5264.       /* Handle difference of two symbolic constants,
  5265.      for the sake of an initializer.  */
  5266.       if ((modifier == EXPAND_SUM || modifier == EXPAND_INITIALIZER)
  5267.       && really_constant_p (TREE_OPERAND (exp, 0))
  5268.       && really_constant_p (TREE_OPERAND (exp, 1)))
  5269.     {
  5270.       rtx op0 = expand_expr (TREE_OPERAND (exp, 0), NULL_RTX,
  5271.                  VOIDmode, modifier);
  5272.       rtx op1 = expand_expr (TREE_OPERAND (exp, 1), NULL_RTX,
  5273.                  VOIDmode, modifier);
  5274.  
  5275.       /* If the last operand is a CONST_INT, use plus_constant of
  5276.          the negated constant.  Else make the MINUS.  */
  5277.       if (GET_CODE (op1) == CONST_INT)
  5278.         return plus_constant (op0, - INTVAL (op1));
  5279.       else
  5280.         return gen_rtx (MINUS, mode, op0, op1);
  5281.     }
  5282.       /* Convert A - const to A + (-const).  */
  5283.       if (TREE_CODE (TREE_OPERAND (exp, 1)) == INTEGER_CST)
  5284.     {
  5285.       tree negated = fold (build1 (NEGATE_EXPR, type,
  5286.                        TREE_OPERAND (exp, 1)));
  5287.  
  5288.       /* Deal with the case where we can't negate the constant
  5289.          in TYPE.  */
  5290.       if (TREE_UNSIGNED (type) || TREE_OVERFLOW (negated))
  5291.         {
  5292.           tree newtype = signed_type (type);
  5293.           tree newop0 = convert (newtype, TREE_OPERAND (exp, 0));
  5294.           tree newop1 = convert (newtype, TREE_OPERAND (exp, 1));
  5295.           tree newneg = fold (build1 (NEGATE_EXPR, newtype, newop1));
  5296.  
  5297.           if (! TREE_OVERFLOW (newneg))
  5298.         return expand_expr (convert (type, 
  5299.                          build (PLUS_EXPR, newtype,
  5300.                             newop0, newneg)),
  5301.                     target, tmode, modifier);
  5302.         }
  5303.       else
  5304.         {
  5305.           exp = build (PLUS_EXPR, type, TREE_OPERAND (exp, 0), negated);
  5306.           goto plus_expr;
  5307.         }
  5308.     }
  5309.       this_optab = sub_optab;
  5310.       goto binop;
  5311.  
  5312.     case MULT_EXPR:
  5313.       preexpand_calls (exp);
  5314.       /* If first operand is constant, swap them.
  5315.      Thus the following special case checks need only
  5316.      check the second operand.  */
  5317.       if (TREE_CODE (TREE_OPERAND (exp, 0)) == INTEGER_CST)
  5318.     {
  5319.       register tree t1 = TREE_OPERAND (exp, 0);
  5320.       TREE_OPERAND (exp, 0) = TREE_OPERAND (exp, 1);
  5321.       TREE_OPERAND (exp, 1) = t1;
  5322.     }
  5323.  
  5324.       /* Attempt to return something suitable for generating an
  5325.      indexed address, for machines that support that.  */
  5326.  
  5327.       if (modifier == EXPAND_SUM && mode == ptr_mode
  5328.       && TREE_CODE (TREE_OPERAND (exp, 1)) == INTEGER_CST
  5329.       && GET_MODE_BITSIZE (mode) <= HOST_BITS_PER_WIDE_INT)
  5330.     {
  5331.       op0 = expand_expr (TREE_OPERAND (exp, 0), subtarget, VOIDmode, EXPAND_SUM);
  5332.  
  5333.       /* Apply distributive law if OP0 is x+c.  */
  5334.       if (GET_CODE (op0) == PLUS
  5335.           && GET_CODE (XEXP (op0, 1)) == CONST_INT)
  5336.         return gen_rtx (PLUS, mode,
  5337.                 gen_rtx (MULT, mode, XEXP (op0, 0),
  5338.                      GEN_INT (TREE_INT_CST_LOW (TREE_OPERAND (exp, 1)))),
  5339.                 GEN_INT (TREE_INT_CST_LOW (TREE_OPERAND (exp, 1))
  5340.                      * INTVAL (XEXP (op0, 1))));
  5341.  
  5342.       if (GET_CODE (op0) != REG)
  5343.         op0 = force_operand (op0, NULL_RTX);
  5344.       if (GET_CODE (op0) != REG)
  5345.         op0 = copy_to_mode_reg (mode, op0);
  5346.  
  5347.       return gen_rtx (MULT, mode, op0,
  5348.               GEN_INT (TREE_INT_CST_LOW (TREE_OPERAND (exp, 1))));
  5349.     }
  5350.  
  5351.       if (! safe_from_p (subtarget, TREE_OPERAND (exp, 1)))
  5352.     subtarget = 0;
  5353.  
  5354.       /* Check for multiplying things that have been extended
  5355.      from a narrower type.  If this machine supports multiplying
  5356.      in that narrower type with a result in the desired type,
  5357.      do it that way, and avoid the explicit type-conversion.  */
  5358.       if (TREE_CODE (TREE_OPERAND (exp, 0)) == NOP_EXPR
  5359.       && TREE_CODE (type) == INTEGER_TYPE
  5360.       && (TYPE_PRECISION (TREE_TYPE (TREE_OPERAND (TREE_OPERAND (exp, 0), 0)))
  5361.           < TYPE_PRECISION (TREE_TYPE (TREE_OPERAND (exp, 0))))
  5362.       && ((TREE_CODE (TREE_OPERAND (exp, 1)) == INTEGER_CST
  5363.            && int_fits_type_p (TREE_OPERAND (exp, 1),
  5364.                    TREE_TYPE (TREE_OPERAND (TREE_OPERAND (exp, 0), 0)))
  5365.            /* Don't use a widening multiply if a shift will do.  */
  5366.            && ((GET_MODE_BITSIZE (TYPE_MODE (TREE_TYPE (TREE_OPERAND (exp, 1))))
  5367.             > HOST_BITS_PER_WIDE_INT)
  5368.            || exact_log2 (TREE_INT_CST_LOW (TREE_OPERAND (exp, 1))) < 0))
  5369.           ||
  5370.           (TREE_CODE (TREE_OPERAND (exp, 1)) == NOP_EXPR
  5371.            && (TYPE_PRECISION (TREE_TYPE (TREE_OPERAND (TREE_OPERAND (exp, 1), 0)))
  5372.            ==
  5373.            TYPE_PRECISION (TREE_TYPE (TREE_OPERAND (TREE_OPERAND (exp, 0), 0))))
  5374.            /* If both operands are extended, they must either both
  5375.           be zero-extended or both be sign-extended.  */
  5376.            && (TREE_UNSIGNED (TREE_TYPE (TREE_OPERAND (TREE_OPERAND (exp, 1), 0)))
  5377.            ==
  5378.            TREE_UNSIGNED (TREE_TYPE (TREE_OPERAND (TREE_OPERAND (exp, 0), 0)))))))
  5379.     {
  5380.       enum machine_mode innermode
  5381.         = TYPE_MODE (TREE_TYPE (TREE_OPERAND (TREE_OPERAND (exp, 0), 0)));
  5382.       this_optab = (TREE_UNSIGNED (TREE_TYPE (TREE_OPERAND (TREE_OPERAND (exp, 0), 0)))
  5383.             ? umul_widen_optab : smul_widen_optab);
  5384.       if (mode == GET_MODE_WIDER_MODE (innermode)
  5385.           && this_optab->handlers[(int) mode].insn_code != CODE_FOR_nothing)
  5386.         {
  5387.           op0 = expand_expr (TREE_OPERAND (TREE_OPERAND (exp, 0), 0),
  5388.                  NULL_RTX, VOIDmode, 0);
  5389.           if (TREE_CODE (TREE_OPERAND (exp, 1)) == INTEGER_CST)
  5390.         op1 = expand_expr (TREE_OPERAND (exp, 1), NULL_RTX,
  5391.                    VOIDmode, 0);
  5392.           else
  5393.         op1 = expand_expr (TREE_OPERAND (TREE_OPERAND (exp, 1), 0),
  5394.                    NULL_RTX, VOIDmode, 0);
  5395.           goto binop2;
  5396.         }
  5397.     }
  5398.       op0 = expand_expr (TREE_OPERAND (exp, 0), subtarget, VOIDmode, 0);
  5399.       op1 = expand_expr (TREE_OPERAND (exp, 1), NULL_RTX, VOIDmode, 0);
  5400.       return expand_mult (mode, op0, op1, target, unsignedp);
  5401.  
  5402.     case TRUNC_DIV_EXPR:
  5403.     case FLOOR_DIV_EXPR:
  5404.     case CEIL_DIV_EXPR:
  5405.     case ROUND_DIV_EXPR:
  5406.     case EXACT_DIV_EXPR:
  5407.       preexpand_calls (exp);
  5408.       if (! safe_from_p (subtarget, TREE_OPERAND (exp, 1)))
  5409.     subtarget = 0;
  5410.       /* Possible optimization: compute the dividend with EXPAND_SUM
  5411.      then if the divisor is constant can optimize the case
  5412.      where some terms of the dividend have coeffs divisible by it.  */
  5413.       op0 = expand_expr (TREE_OPERAND (exp, 0), subtarget, VOIDmode, 0);
  5414.       op1 = expand_expr (TREE_OPERAND (exp, 1), NULL_RTX, VOIDmode, 0);
  5415.       return expand_divmod (0, code, mode, op0, op1, target, unsignedp);
  5416.  
  5417.     case RDIV_EXPR:
  5418.       this_optab = flodiv_optab;
  5419.       goto binop;
  5420.  
  5421.     case TRUNC_MOD_EXPR:
  5422.     case FLOOR_MOD_EXPR:
  5423.     case CEIL_MOD_EXPR:
  5424.     case ROUND_MOD_EXPR:
  5425.       preexpand_calls (exp);
  5426.       if (! safe_from_p (subtarget, TREE_OPERAND (exp, 1)))
  5427.     subtarget = 0;
  5428.       op0 = expand_expr (TREE_OPERAND (exp, 0), subtarget, VOIDmode, 0);
  5429.       op1 = expand_expr (TREE_OPERAND (exp, 1), NULL_RTX, VOIDmode, 0);
  5430.       return expand_divmod (1, code, mode, op0, op1, target, unsignedp);
  5431.  
  5432.     case FIX_ROUND_EXPR:
  5433.     case FIX_FLOOR_EXPR:
  5434.     case FIX_CEIL_EXPR:
  5435.       abort ();            /* Not used for C.  */
  5436.  
  5437.     case FIX_TRUNC_EXPR:
  5438.       op0 = expand_expr (TREE_OPERAND (exp, 0), NULL_RTX, VOIDmode, 0);
  5439.       if (target == 0)
  5440.     target = gen_reg_rtx (mode);
  5441.       expand_fix (target, op0, unsignedp);
  5442.       return target;
  5443.  
  5444.     case FLOAT_EXPR:
  5445.       op0 = expand_expr (TREE_OPERAND (exp, 0), NULL_RTX, VOIDmode, 0);
  5446.       if (target == 0)
  5447.     target = gen_reg_rtx (mode);
  5448.       /* expand_float can't figure out what to do if FROM has VOIDmode.
  5449.      So give it the correct mode.  With -O, cse will optimize this.  */
  5450.       if (GET_MODE (op0) == VOIDmode)
  5451.     op0 = copy_to_mode_reg (TYPE_MODE (TREE_TYPE (TREE_OPERAND (exp, 0))),
  5452.                 op0);
  5453.       expand_float (target, op0,
  5454.             TREE_UNSIGNED (TREE_TYPE (TREE_OPERAND (exp, 0))));
  5455.       return target;
  5456.  
  5457.     case NEGATE_EXPR:
  5458.       op0 = expand_expr (TREE_OPERAND (exp, 0), subtarget, VOIDmode, 0);
  5459.       temp = expand_unop (mode, neg_optab, op0, target, 0);
  5460.       if (temp == 0)
  5461.     abort ();
  5462.       return temp;
  5463.  
  5464.     case ABS_EXPR:
  5465.       op0 = expand_expr (TREE_OPERAND (exp, 0), subtarget, VOIDmode, 0);
  5466.  
  5467.       /* Handle complex values specially.  */
  5468.       if (GET_MODE_CLASS (mode) == MODE_COMPLEX_INT
  5469.       || GET_MODE_CLASS (mode) == MODE_COMPLEX_FLOAT)
  5470.     return expand_complex_abs (mode, op0, target, unsignedp);
  5471.  
  5472.       /* Unsigned abs is simply the operand.  Testing here means we don't
  5473.      risk generating incorrect code below.  */
  5474.       if (TREE_UNSIGNED (type))
  5475.     return op0;
  5476.  
  5477.       return expand_abs (mode, op0, target, unsignedp,
  5478.              safe_from_p (target, TREE_OPERAND (exp, 0)));
  5479.  
  5480.     case MAX_EXPR:
  5481.     case MIN_EXPR:
  5482.       target = original_target;
  5483.       if (target == 0 || ! safe_from_p (target, TREE_OPERAND (exp, 1))
  5484.       || (GET_CODE (target) == MEM && MEM_VOLATILE_P (target))
  5485.       || GET_MODE (target) != mode
  5486.       || (GET_CODE (target) == REG
  5487.           && REGNO (target) < FIRST_PSEUDO_REGISTER))
  5488.     target = gen_reg_rtx (mode);
  5489.       op1 = expand_expr (TREE_OPERAND (exp, 1), NULL_RTX, VOIDmode, 0);
  5490.       op0 = expand_expr (TREE_OPERAND (exp, 0), target, VOIDmode, 0);
  5491.  
  5492.       /* First try to do it with a special MIN or MAX instruction.
  5493.      If that does not win, use a conditional jump to select the proper
  5494.      value.  */
  5495.       this_optab = (TREE_UNSIGNED (type)
  5496.             ? (code == MIN_EXPR ? umin_optab : umax_optab)
  5497.             : (code == MIN_EXPR ? smin_optab : smax_optab));
  5498.  
  5499.       temp = expand_binop (mode, this_optab, op0, op1, target, unsignedp,
  5500.                OPTAB_WIDEN);
  5501.       if (temp != 0)
  5502.     return temp;
  5503.  
  5504.       /* At this point, a MEM target is no longer useful; we will get better
  5505.      code without it.  */
  5506.      
  5507.       if (GET_CODE (target) == MEM)
  5508.     target = gen_reg_rtx (mode);
  5509.  
  5510.       if (target != op0)
  5511.     emit_move_insn (target, op0);
  5512.  
  5513.       op0 = gen_label_rtx ();
  5514.  
  5515.       /* If this mode is an integer too wide to compare properly,
  5516.      compare word by word.  Rely on cse to optimize constant cases.  */
  5517.       if (GET_MODE_CLASS (mode) == MODE_INT && !can_compare_p (mode))
  5518.     {
  5519.       if (code == MAX_EXPR)
  5520.         do_jump_by_parts_greater_rtx (mode, TREE_UNSIGNED (type),
  5521.                       target, op1, NULL_RTX, op0);
  5522.       else
  5523.         do_jump_by_parts_greater_rtx (mode, TREE_UNSIGNED (type),
  5524.                       op1, target, NULL_RTX, op0);
  5525.       emit_move_insn (target, op1);
  5526.     }
  5527.       else
  5528.     {
  5529.       if (code == MAX_EXPR)
  5530.         temp = (TREE_UNSIGNED (TREE_TYPE (TREE_OPERAND (exp, 1)))
  5531.             ? compare_from_rtx (target, op1, GEU, 1, mode, NULL_RTX, 0)
  5532.             : compare_from_rtx (target, op1, GE, 0, mode, NULL_RTX, 0));
  5533.       else
  5534.         temp = (TREE_UNSIGNED (TREE_TYPE (TREE_OPERAND (exp, 1)))
  5535.             ? compare_from_rtx (target, op1, LEU, 1, mode, NULL_RTX, 0)
  5536.             : compare_from_rtx (target, op1, LE, 0, mode, NULL_RTX, 0));
  5537.       if (temp == const0_rtx)
  5538.         emit_move_insn (target, op1);
  5539.       else if (temp != const_true_rtx)
  5540.         {
  5541.           if (bcc_gen_fctn[(int) GET_CODE (temp)] != 0)
  5542.         emit_jump_insn ((*bcc_gen_fctn[(int) GET_CODE (temp)]) (op0));
  5543.           else
  5544.         abort ();
  5545.           emit_move_insn (target, op1);
  5546.         }
  5547.     }
  5548.       emit_label (op0);
  5549.       return target;
  5550.  
  5551.     case BIT_NOT_EXPR:
  5552.       op0 = expand_expr (TREE_OPERAND (exp, 0), subtarget, VOIDmode, 0);
  5553.       temp = expand_unop (mode, one_cmpl_optab, op0, target, 1);
  5554.       if (temp == 0)
  5555.     abort ();
  5556.       return temp;
  5557.  
  5558.     case FFS_EXPR:
  5559.       op0 = expand_expr (TREE_OPERAND (exp, 0), subtarget, VOIDmode, 0);
  5560.       temp = expand_unop (mode, ffs_optab, op0, target, 1);
  5561.       if (temp == 0)
  5562.     abort ();
  5563.       return temp;
  5564.  
  5565.       /* ??? Can optimize bitwise operations with one arg constant.
  5566.      Can optimize (a bitwise1 n) bitwise2 (a bitwise3 b)
  5567.      and (a bitwise1 b) bitwise2 b (etc)
  5568.      but that is probably not worth while.  */
  5569.  
  5570.       /* BIT_AND_EXPR is for bitwise anding.  TRUTH_AND_EXPR is for anding two
  5571.      boolean values when we want in all cases to compute both of them.  In
  5572.      general it is fastest to do TRUTH_AND_EXPR by computing both operands
  5573.      as actual zero-or-1 values and then bitwise anding.  In cases where
  5574.      there cannot be any side effects, better code would be made by
  5575.      treating TRUTH_AND_EXPR like TRUTH_ANDIF_EXPR; but the question is
  5576.      how to recognize those cases.  */
  5577.  
  5578.     case TRUTH_AND_EXPR:
  5579.     case BIT_AND_EXPR:
  5580.       this_optab = and_optab;
  5581.       goto binop;
  5582.  
  5583.     case TRUTH_OR_EXPR:
  5584.     case BIT_IOR_EXPR:
  5585.       this_optab = ior_optab;
  5586.       goto binop;
  5587.  
  5588.     case TRUTH_XOR_EXPR:
  5589.     case BIT_XOR_EXPR:
  5590.       this_optab = xor_optab;
  5591.       goto binop;
  5592.  
  5593.     case LSHIFT_EXPR:
  5594.     case RSHIFT_EXPR:
  5595.     case LROTATE_EXPR:
  5596.     case RROTATE_EXPR:
  5597.       preexpand_calls (exp);
  5598.       if (! safe_from_p (subtarget, TREE_OPERAND (exp, 1)))
  5599.     subtarget = 0;
  5600.       op0 = expand_expr (TREE_OPERAND (exp, 0), subtarget, VOIDmode, 0);
  5601.       return expand_shift (code, mode, op0, TREE_OPERAND (exp, 1), target,
  5602.                unsignedp);
  5603.  
  5604.       /* Could determine the answer when only additive constants differ.  Also,
  5605.      the addition of one can be handled by changing the condition.  */
  5606.     case LT_EXPR:
  5607.     case LE_EXPR:
  5608.     case GT_EXPR:
  5609.     case GE_EXPR:
  5610.     case EQ_EXPR:
  5611.     case NE_EXPR:
  5612.       preexpand_calls (exp);
  5613.       temp = do_store_flag (exp, target, tmode != VOIDmode ? tmode : mode, 0);
  5614.       if (temp != 0)
  5615.     return temp;
  5616.  
  5617.       /* For foo != 0, load foo, and if it is nonzero load 1 instead. */
  5618.       if (code == NE_EXPR && integer_zerop (TREE_OPERAND (exp, 1))
  5619.       && original_target
  5620.       && GET_CODE (original_target) == REG
  5621.       && (GET_MODE (original_target)
  5622.           == TYPE_MODE (TREE_TYPE (TREE_OPERAND (exp, 0)))))
  5623.     {
  5624.       temp = expand_expr (TREE_OPERAND (exp, 0), original_target,
  5625.                   VOIDmode, 0);
  5626.  
  5627.       if (temp != original_target)
  5628.         temp = copy_to_reg (temp);
  5629.  
  5630.       op1 = gen_label_rtx ();
  5631.       emit_cmp_insn (temp, const0_rtx, EQ, NULL_RTX,
  5632.              GET_MODE (temp), unsignedp, 0);
  5633.       emit_jump_insn (gen_beq (op1));
  5634.       emit_move_insn (temp, const1_rtx);
  5635.       emit_label (op1);
  5636.       return temp;
  5637.     }
  5638.  
  5639.       /* If no set-flag instruction, must generate a conditional
  5640.      store into a temporary variable.  Drop through
  5641.      and handle this like && and ||.  */
  5642.  
  5643.     case TRUTH_ANDIF_EXPR:
  5644.     case TRUTH_ORIF_EXPR:
  5645.       if (! ignore
  5646.       && (target == 0 || ! safe_from_p (target, exp)
  5647.           /* Make sure we don't have a hard reg (such as function's return
  5648.          value) live across basic blocks, if not optimizing.  */
  5649.           || (!optimize && GET_CODE (target) == REG
  5650.           && REGNO (target) < FIRST_PSEUDO_REGISTER)))
  5651.     target = gen_reg_rtx (tmode != VOIDmode ? tmode : mode);
  5652.  
  5653.       if (target)
  5654.     emit_clr_insn (target);
  5655.  
  5656.       op1 = gen_label_rtx ();
  5657.       jumpifnot (exp, op1);
  5658.  
  5659.       if (target)
  5660.     emit_0_to_1_insn (target);
  5661.  
  5662.       emit_label (op1);
  5663.       return ignore ? const0_rtx : target;
  5664.  
  5665.     case TRUTH_NOT_EXPR:
  5666.       op0 = expand_expr (TREE_OPERAND (exp, 0), target, VOIDmode, 0);
  5667.       /* The parser is careful to generate TRUTH_NOT_EXPR
  5668.      only with operands that are always zero or one.  */
  5669.       temp = expand_binop (mode, xor_optab, op0, const1_rtx,
  5670.                target, 1, OPTAB_LIB_WIDEN);
  5671.       if (temp == 0)
  5672.     abort ();
  5673.       return temp;
  5674.  
  5675.     case COMPOUND_EXPR:
  5676.       expand_expr (TREE_OPERAND (exp, 0), const0_rtx, VOIDmode, 0);
  5677.       emit_queue ();
  5678.       return expand_expr (TREE_OPERAND (exp, 1),
  5679.               (ignore ? const0_rtx : target),
  5680.               VOIDmode, 0);
  5681.  
  5682.     case COND_EXPR:
  5683.       {
  5684.     rtx flag = NULL_RTX;
  5685.     tree left_cleanups = NULL_TREE;
  5686.     tree right_cleanups = NULL_TREE;
  5687.  
  5688.     /* Used to save a pointer to the place to put the setting of
  5689.        the flag that indicates if this side of the conditional was
  5690.        taken.  We backpatch the code, if we find out later that we
  5691.        have any conditional cleanups that need to be performed. */
  5692.     rtx dest_right_flag = NULL_RTX;
  5693.     rtx dest_left_flag = NULL_RTX;
  5694.  
  5695.     /* Note that COND_EXPRs whose type is a structure or union
  5696.        are required to be constructed to contain assignments of
  5697.        a temporary variable, so that we can evaluate them here
  5698.        for side effect only.  If type is void, we must do likewise.  */
  5699.  
  5700.     /* If an arm of the branch requires a cleanup,
  5701.        only that cleanup is performed.  */
  5702.  
  5703.     tree singleton = 0;
  5704.     tree binary_op = 0, unary_op = 0;
  5705.     tree old_cleanups = cleanups_this_call;
  5706.  
  5707.     /* If this is (A ? 1 : 0) and A is a condition, just evaluate it and
  5708.        convert it to our mode, if necessary.  */
  5709.     if (integer_onep (TREE_OPERAND (exp, 1))
  5710.         && integer_zerop (TREE_OPERAND (exp, 2))
  5711.         && TREE_CODE_CLASS (TREE_CODE (TREE_OPERAND (exp, 0))) == '<')
  5712.       {
  5713.         if (ignore)
  5714.           {
  5715.         expand_expr (TREE_OPERAND (exp, 0), const0_rtx, VOIDmode,
  5716.                  modifier);
  5717.         return const0_rtx;
  5718.           }
  5719.  
  5720.         op0 = expand_expr (TREE_OPERAND (exp, 0), target, mode, modifier);
  5721.         if (GET_MODE (op0) == mode)
  5722.           return op0;
  5723.  
  5724.         if (target == 0)
  5725.           target = gen_reg_rtx (mode);
  5726.         convert_move (target, op0, unsignedp);
  5727.         return target;
  5728.       }
  5729.  
  5730.     /* If we are not to produce a result, we have no target.  Otherwise,
  5731.        if a target was specified use it; it will not be used as an
  5732.        intermediate target unless it is safe.  If no target, use a 
  5733.        temporary.  */
  5734.  
  5735.     if (ignore)
  5736.       temp = 0;
  5737.     else if (original_target
  5738.          && safe_from_p (original_target, TREE_OPERAND (exp, 0))
  5739.          && GET_MODE (original_target) == mode
  5740.          && ! (GET_CODE (original_target) == MEM
  5741.                && MEM_VOLATILE_P (original_target)))
  5742.       temp = original_target;
  5743.     else if (mode == BLKmode)
  5744.       {
  5745.         if (TYPE_SIZE (type) == 0
  5746.         || TREE_CODE (TYPE_SIZE (type)) != INTEGER_CST)
  5747.           abort ();
  5748.  
  5749.         temp = assign_stack_temp (BLKmode,
  5750.                       (TREE_INT_CST_LOW (TYPE_SIZE (type))
  5751.                        + BITS_PER_UNIT - 1)
  5752.                       / BITS_PER_UNIT, 0);
  5753.         MEM_IN_STRUCT_P (temp) = AGGREGATE_TYPE_P (type);
  5754.       }
  5755.     else
  5756.       temp = gen_reg_rtx (mode);
  5757.  
  5758.     /* Check for X ? A + B : A.  If we have this, we can copy
  5759.        A to the output and conditionally add B.  Similarly for unary
  5760.        operations.  Don't do this if X has side-effects because
  5761.        those side effects might affect A or B and the "?" operation is
  5762.        a sequence point in ANSI.  (We test for side effects later.)  */
  5763.  
  5764.     if (TREE_CODE_CLASS (TREE_CODE (TREE_OPERAND (exp, 1))) == '2'
  5765.         && operand_equal_p (TREE_OPERAND (exp, 2),
  5766.                 TREE_OPERAND (TREE_OPERAND (exp, 1), 0), 0))
  5767.       singleton = TREE_OPERAND (exp, 2), binary_op = TREE_OPERAND (exp, 1);
  5768.     else if (TREE_CODE_CLASS (TREE_CODE (TREE_OPERAND (exp, 2))) == '2'
  5769.          && operand_equal_p (TREE_OPERAND (exp, 1),
  5770.                      TREE_OPERAND (TREE_OPERAND (exp, 2), 0), 0))
  5771.       singleton = TREE_OPERAND (exp, 1), binary_op = TREE_OPERAND (exp, 2);
  5772.     else if (TREE_CODE_CLASS (TREE_CODE (TREE_OPERAND (exp, 1))) == '1'
  5773.          && operand_equal_p (TREE_OPERAND (exp, 2),
  5774.                      TREE_OPERAND (TREE_OPERAND (exp, 1), 0), 0))
  5775.       singleton = TREE_OPERAND (exp, 2), unary_op = TREE_OPERAND (exp, 1);
  5776.     else if (TREE_CODE_CLASS (TREE_CODE (TREE_OPERAND (exp, 2))) == '1'
  5777.          && operand_equal_p (TREE_OPERAND (exp, 1),
  5778.                      TREE_OPERAND (TREE_OPERAND (exp, 2), 0), 0))
  5779.       singleton = TREE_OPERAND (exp, 1), unary_op = TREE_OPERAND (exp, 2);
  5780.  
  5781.     /* If we had X ? A + 1 : A and we can do the test of X as a store-flag
  5782.        operation, do this as A + (X != 0).  Similarly for other simple
  5783.        binary operators.  */
  5784.     if (temp && singleton && binary_op
  5785.         && ! TREE_SIDE_EFFECTS (TREE_OPERAND (exp, 0))
  5786.         && (TREE_CODE (binary_op) == PLUS_EXPR
  5787.         || TREE_CODE (binary_op) == MINUS_EXPR
  5788.         || TREE_CODE (binary_op) == BIT_IOR_EXPR
  5789.         || TREE_CODE (binary_op) == BIT_XOR_EXPR)
  5790.         && integer_onep (TREE_OPERAND (binary_op, 1))
  5791.         && TREE_CODE_CLASS (TREE_CODE (TREE_OPERAND (exp, 0))) == '<')
  5792.       {
  5793.         rtx result;
  5794.         optab boptab = (TREE_CODE (binary_op) == PLUS_EXPR ? add_optab
  5795.                 : TREE_CODE (binary_op) == MINUS_EXPR ? sub_optab
  5796.                 : TREE_CODE (binary_op) == BIT_IOR_EXPR ? ior_optab
  5797.                 : xor_optab);
  5798.  
  5799.         /* If we had X ? A : A + 1, do this as A + (X == 0).
  5800.  
  5801.            We have to invert the truth value here and then put it
  5802.            back later if do_store_flag fails.  We cannot simply copy
  5803.            TREE_OPERAND (exp, 0) to another variable and modify that
  5804.            because invert_truthvalue can modify the tree pointed to
  5805.            by its argument.  */
  5806.         if (singleton == TREE_OPERAND (exp, 1))
  5807.           TREE_OPERAND (exp, 0)
  5808.         = invert_truthvalue (TREE_OPERAND (exp, 0));
  5809.  
  5810.         result = do_store_flag (TREE_OPERAND (exp, 0),
  5811.                     (safe_from_p (temp, singleton)
  5812.                      ? temp : NULL_RTX),
  5813.                     mode, BRANCH_COST <= 1);
  5814.  
  5815.         if (result)
  5816.           {
  5817.         op1 = expand_expr (singleton, NULL_RTX, VOIDmode, 0);
  5818.         return expand_binop (mode, boptab, op1, result, temp,
  5819.                      unsignedp, OPTAB_LIB_WIDEN);
  5820.           }
  5821.         else if (singleton == TREE_OPERAND (exp, 1))
  5822.           TREE_OPERAND (exp, 0)
  5823.         = invert_truthvalue (TREE_OPERAND (exp, 0));
  5824.       }
  5825.         
  5826.     NO_DEFER_POP;
  5827.     op0 = gen_label_rtx ();
  5828.  
  5829.     flag = gen_reg_rtx (word_mode);
  5830.     if (singleton && ! TREE_SIDE_EFFECTS (TREE_OPERAND (exp, 0)))
  5831.       {
  5832.         if (temp != 0)
  5833.           {
  5834.         /* If the target conflicts with the other operand of the
  5835.            binary op, we can't use it.  Also, we can't use the target
  5836.            if it is a hard register, because evaluating the condition
  5837.            might clobber it.  */
  5838.         if ((binary_op
  5839.              && ! safe_from_p (temp, TREE_OPERAND (binary_op, 1)))
  5840.             || (GET_CODE (temp) == REG
  5841.             && REGNO (temp) < FIRST_PSEUDO_REGISTER))
  5842.           temp = gen_reg_rtx (mode);
  5843.         store_expr (singleton, temp, 0);
  5844.           }
  5845.         else
  5846.           expand_expr (singleton,
  5847.                ignore ? const0_rtx : NULL_RTX, VOIDmode, 0);
  5848.         dest_left_flag = get_last_insn ();
  5849.         if (singleton == TREE_OPERAND (exp, 1))
  5850.           jumpif (TREE_OPERAND (exp, 0), op0);
  5851.         else
  5852.           jumpifnot (TREE_OPERAND (exp, 0), op0);
  5853.  
  5854.         /* Allows cleanups up to here. */
  5855.         old_cleanups = cleanups_this_call;
  5856.         if (binary_op && temp == 0)
  5857.           /* Just touch the other operand.  */
  5858.           expand_expr (TREE_OPERAND (binary_op, 1),
  5859.                ignore ? const0_rtx : NULL_RTX, VOIDmode, 0);
  5860.         else if (binary_op)
  5861.           store_expr (build (TREE_CODE (binary_op), type,
  5862.                  make_tree (type, temp),
  5863.                  TREE_OPERAND (binary_op, 1)),
  5864.               temp, 0);
  5865.         else
  5866.           store_expr (build1 (TREE_CODE (unary_op), type,
  5867.                   make_tree (type, temp)),
  5868.               temp, 0);
  5869.         op1 = op0;
  5870.         dest_right_flag = get_last_insn ();
  5871.       }
  5872. #if 0
  5873.     /* This is now done in jump.c and is better done there because it
  5874.        produces shorter register lifetimes.  */
  5875.        
  5876.     /* Check for both possibilities either constants or variables
  5877.        in registers (but not the same as the target!).  If so, can
  5878.        save branches by assigning one, branching, and assigning the
  5879.        other.  */
  5880.     else if (temp && GET_MODE (temp) != BLKmode
  5881.          && (TREE_CONSTANT (TREE_OPERAND (exp, 1))
  5882.              || ((TREE_CODE (TREE_OPERAND (exp, 1)) == PARM_DECL
  5883.               || TREE_CODE (TREE_OPERAND (exp, 1)) == VAR_DECL)
  5884.              && DECL_RTL (TREE_OPERAND (exp, 1))
  5885.              && GET_CODE (DECL_RTL (TREE_OPERAND (exp, 1))) == REG
  5886.              && DECL_RTL (TREE_OPERAND (exp, 1)) != temp))
  5887.          && (TREE_CONSTANT (TREE_OPERAND (exp, 2))
  5888.              || ((TREE_CODE (TREE_OPERAND (exp, 2)) == PARM_DECL
  5889.               || TREE_CODE (TREE_OPERAND (exp, 2)) == VAR_DECL)
  5890.              && DECL_RTL (TREE_OPERAND (exp, 2))
  5891.              && GET_CODE (DECL_RTL (TREE_OPERAND (exp, 2))) == REG
  5892.              && DECL_RTL (TREE_OPERAND (exp, 2)) != temp)))
  5893.       {
  5894.         if (GET_CODE (temp) == REG && REGNO (temp) < FIRST_PSEUDO_REGISTER)
  5895.           temp = gen_reg_rtx (mode);
  5896.         store_expr (TREE_OPERAND (exp, 2), temp, 0);
  5897.         dest_left_flag = get_last_insn ();
  5898.         jumpifnot (TREE_OPERAND (exp, 0), op0);
  5899.  
  5900.         /* Allows cleanups up to here. */
  5901.         old_cleanups = cleanups_this_call;
  5902.         store_expr (TREE_OPERAND (exp, 1), temp, 0);
  5903.         op1 = op0;
  5904.         dest_right_flag = get_last_insn ();
  5905.       }
  5906. #endif
  5907.     /* Check for A op 0 ? A : FOO and A op 0 ? FOO : A where OP is any
  5908.        comparison operator.  If we have one of these cases, set the
  5909.        output to A, branch on A (cse will merge these two references),
  5910.        then set the output to FOO.  */
  5911.     else if (temp
  5912.          && TREE_CODE_CLASS (TREE_CODE (TREE_OPERAND (exp, 0))) == '<'
  5913.          && integer_zerop (TREE_OPERAND (TREE_OPERAND (exp, 0), 1))
  5914.          && operand_equal_p (TREE_OPERAND (TREE_OPERAND (exp, 0), 0),
  5915.                      TREE_OPERAND (exp, 1), 0)
  5916.          && ! TREE_SIDE_EFFECTS (TREE_OPERAND (exp, 0))
  5917.          && safe_from_p (temp, TREE_OPERAND (exp, 2)))
  5918.       {
  5919.         if (GET_CODE (temp) == REG && REGNO (temp) < FIRST_PSEUDO_REGISTER)
  5920.           temp = gen_reg_rtx (mode);
  5921.         store_expr (TREE_OPERAND (exp, 1), temp, 0);
  5922.         dest_left_flag = get_last_insn ();
  5923.         jumpif (TREE_OPERAND (exp, 0), op0);
  5924.  
  5925.         /* Allows cleanups up to here. */
  5926.         old_cleanups = cleanups_this_call;
  5927.         store_expr (TREE_OPERAND (exp, 2), temp, 0);
  5928.         op1 = op0;
  5929.         dest_right_flag = get_last_insn ();
  5930.       }
  5931.     else if (temp
  5932.          && TREE_CODE_CLASS (TREE_CODE (TREE_OPERAND (exp, 0))) == '<'
  5933.          && integer_zerop (TREE_OPERAND (TREE_OPERAND (exp, 0), 1))
  5934.          && operand_equal_p (TREE_OPERAND (TREE_OPERAND (exp, 0), 0),
  5935.                      TREE_OPERAND (exp, 2), 0)
  5936.          && ! TREE_SIDE_EFFECTS (TREE_OPERAND (exp, 0))
  5937.          && safe_from_p (temp, TREE_OPERAND (exp, 1)))
  5938.       {
  5939.         if (GET_CODE (temp) == REG && REGNO (temp) < FIRST_PSEUDO_REGISTER)
  5940.           temp = gen_reg_rtx (mode);
  5941.         store_expr (TREE_OPERAND (exp, 2), temp, 0);
  5942.         dest_left_flag = get_last_insn ();
  5943.         jumpifnot (TREE_OPERAND (exp, 0), op0);
  5944.  
  5945.         /* Allows cleanups up to here. */
  5946.         old_cleanups = cleanups_this_call;
  5947.         store_expr (TREE_OPERAND (exp, 1), temp, 0);
  5948.         op1 = op0;
  5949.         dest_right_flag = get_last_insn ();
  5950.       }
  5951.     else
  5952.       {
  5953.         op1 = gen_label_rtx ();
  5954.         jumpifnot (TREE_OPERAND (exp, 0), op0);
  5955.  
  5956.         /* Allows cleanups up to here. */
  5957.         old_cleanups = cleanups_this_call;
  5958.         if (temp != 0)
  5959.           store_expr (TREE_OPERAND (exp, 1), temp, 0);
  5960.         else
  5961.           expand_expr (TREE_OPERAND (exp, 1),
  5962.                ignore ? const0_rtx : NULL_RTX, VOIDmode, 0);
  5963.         dest_left_flag = get_last_insn ();
  5964.  
  5965.         /* Handle conditional cleanups, if any. */
  5966.         left_cleanups = defer_cleanups_to (old_cleanups);
  5967.  
  5968.         emit_queue ();
  5969.         emit_jump_insn (gen_jump (op1));
  5970.         emit_barrier ();
  5971.         emit_label (op0);
  5972.         if (temp != 0)
  5973.           store_expr (TREE_OPERAND (exp, 2), temp, 0);
  5974.         else
  5975.           expand_expr (TREE_OPERAND (exp, 2),
  5976.                ignore ? const0_rtx : NULL_RTX, VOIDmode, 0);
  5977.         dest_right_flag = get_last_insn ();
  5978.       }
  5979.  
  5980.     /* Handle conditional cleanups, if any. */
  5981.     right_cleanups = defer_cleanups_to (old_cleanups);
  5982.  
  5983.     emit_queue ();
  5984.     emit_label (op1);
  5985.     OK_DEFER_POP;
  5986.  
  5987.     /* Add back in, any conditional cleanups. */
  5988.     if (left_cleanups || right_cleanups)
  5989.       {
  5990.         tree new_cleanups;
  5991.         tree cond;
  5992.         rtx last;
  5993.  
  5994.         /* Now that we know that a flag is needed, go back and add in the
  5995.            setting of the flag. */
  5996.  
  5997.         /* Do the left side flag. */
  5998.         last = get_last_insn ();
  5999.         /* Flag left cleanups as needed. */
  6000.         emit_move_insn (flag, const1_rtx);
  6001.         /* ??? deprecated, use sequences instead.  */
  6002.         reorder_insns (NEXT_INSN (last), get_last_insn (), dest_left_flag);
  6003.  
  6004.         /* Do the right side flag. */
  6005.         last = get_last_insn ();
  6006.         /* Flag left cleanups as needed. */
  6007.         emit_move_insn (flag, const0_rtx);
  6008.         /* ??? deprecated, use sequences instead.  */
  6009.         reorder_insns (NEXT_INSN (last), get_last_insn (), dest_right_flag);
  6010.  
  6011.         /* convert flag, which is an rtx, into a tree. */
  6012.         cond = make_node (RTL_EXPR);
  6013.         TREE_TYPE (cond) = integer_type_node;
  6014.         RTL_EXPR_RTL (cond) = flag;
  6015.         RTL_EXPR_SEQUENCE (cond) = NULL_RTX;
  6016.  
  6017.         if (! left_cleanups)
  6018.           left_cleanups = integer_zero_node;
  6019.         if (! right_cleanups)
  6020.           right_cleanups = integer_zero_node;
  6021.         new_cleanups = build (COND_EXPR, void_type_node,
  6022.                   truthvalue_conversion (cond),
  6023.                   left_cleanups, right_cleanups);
  6024.         new_cleanups = fold (new_cleanups);
  6025.  
  6026.         /* Now add in the conditionalized cleanups. */
  6027.         cleanups_this_call
  6028.           = tree_cons (NULL_TREE, new_cleanups, cleanups_this_call);
  6029.         (*interim_eh_hook) (NULL_TREE);
  6030.       }
  6031.     return temp;
  6032.       }
  6033.  
  6034.     case TARGET_EXPR:
  6035.       {
  6036.     int need_exception_region = 0;
  6037.     /* Something needs to be initialized, but we didn't know
  6038.        where that thing was when building the tree.  For example,
  6039.        it could be the return value of a function, or a parameter
  6040.        to a function which lays down in the stack, or a temporary
  6041.        variable which must be passed by reference.
  6042.  
  6043.        We guarantee that the expression will either be constructed
  6044.        or copied into our original target.  */
  6045.  
  6046.     tree slot = TREE_OPERAND (exp, 0);
  6047.     tree exp1;
  6048.     rtx temp;
  6049.  
  6050.     if (TREE_CODE (slot) != VAR_DECL)
  6051.       abort ();
  6052.  
  6053.     if (target == 0)
  6054.       {
  6055.         if (DECL_RTL (slot) != 0)
  6056.           {
  6057.         target = DECL_RTL (slot);
  6058.         /* If we have already expanded the slot, so don't do
  6059.            it again.  (mrs)  */
  6060.         if (TREE_OPERAND (exp, 1) == NULL_TREE)
  6061.           return target;
  6062.           }
  6063.         else
  6064.           {
  6065.         target = assign_stack_temp (mode, int_size_in_bytes (type), 2);
  6066.         MEM_IN_STRUCT_P (target) = AGGREGATE_TYPE_P (type);
  6067.         /* All temp slots at this level must not conflict.  */
  6068.         preserve_temp_slots (target);
  6069.         DECL_RTL (slot) = target;
  6070.  
  6071.         /* Since SLOT is not known to the called function
  6072.            to belong to its stack frame, we must build an explicit
  6073.            cleanup.  This case occurs when we must build up a reference
  6074.            to pass the reference as an argument.  In this case,
  6075.            it is very likely that such a reference need not be
  6076.            built here.  */
  6077.  
  6078.         if (TREE_OPERAND (exp, 2) == 0)
  6079.           TREE_OPERAND (exp, 2) = maybe_build_cleanup (slot);
  6080.         if (TREE_OPERAND (exp, 2))
  6081.           {
  6082.             cleanups_this_call = tree_cons (NULL_TREE,
  6083.                             TREE_OPERAND (exp, 2),
  6084.                             cleanups_this_call);
  6085.             need_exception_region = 1;
  6086.           }
  6087.           }
  6088.       }
  6089.     else
  6090.       {
  6091.         /* This case does occur, when expanding a parameter which
  6092.            needs to be constructed on the stack.  The target
  6093.            is the actual stack address that we want to initialize.
  6094.            The function we call will perform the cleanup in this case.  */
  6095.  
  6096.         /* If we have already assigned it space, use that space,
  6097.            not target that we were passed in, as our target
  6098.            parameter is only a hint.  */
  6099.         if (DECL_RTL (slot) != 0)
  6100.               {
  6101.                 target = DECL_RTL (slot);
  6102.                 /* If we have already expanded the slot, so don't do
  6103.                    it again.  (mrs)  */
  6104.                 if (TREE_OPERAND (exp, 1) == NULL_TREE)
  6105.                   return target;
  6106.           }
  6107.  
  6108.         DECL_RTL (slot) = target;
  6109.       }
  6110.  
  6111.     exp1 = TREE_OPERAND (exp, 1);
  6112.     /* Mark it as expanded.  */
  6113.     TREE_OPERAND (exp, 1) = NULL_TREE;
  6114.  
  6115.     temp = expand_expr (exp1, target, tmode, modifier);
  6116.  
  6117.     if (need_exception_region)
  6118.       (*interim_eh_hook) (NULL_TREE);
  6119.     
  6120.     return temp;
  6121.       }
  6122.  
  6123.     case INIT_EXPR:
  6124.       {
  6125.     tree lhs = TREE_OPERAND (exp, 0);
  6126.     tree rhs = TREE_OPERAND (exp, 1);
  6127.     tree noncopied_parts = 0;
  6128.     tree lhs_type = TREE_TYPE (lhs);
  6129.  
  6130.     temp = expand_assignment (lhs, rhs, ! ignore, original_target != 0);
  6131.     if (TYPE_NONCOPIED_PARTS (lhs_type) != 0 && !fixed_type_p (rhs))
  6132.       noncopied_parts = init_noncopied_parts (stabilize_reference (lhs),
  6133.                           TYPE_NONCOPIED_PARTS (lhs_type));
  6134.     while (noncopied_parts != 0)
  6135.       {
  6136.         expand_assignment (TREE_VALUE (noncopied_parts),
  6137.                    TREE_PURPOSE (noncopied_parts), 0, 0);
  6138.         noncopied_parts = TREE_CHAIN (noncopied_parts);
  6139.       }
  6140.     return temp;
  6141.       }
  6142.  
  6143.     case MODIFY_EXPR:
  6144.       {
  6145.     /* If lhs is complex, expand calls in rhs before computing it.
  6146.        That's so we don't compute a pointer and save it over a call.
  6147.        If lhs is simple, compute it first so we can give it as a
  6148.        target if the rhs is just a call.  This avoids an extra temp and copy
  6149.        and that prevents a partial-subsumption which makes bad code.
  6150.        Actually we could treat component_ref's of vars like vars.  */
  6151.  
  6152.     tree lhs = TREE_OPERAND (exp, 0);
  6153.     tree rhs = TREE_OPERAND (exp, 1);
  6154.     tree noncopied_parts = 0;
  6155.     tree lhs_type = TREE_TYPE (lhs);
  6156.  
  6157.     temp = 0;
  6158.  
  6159.     if (TREE_CODE (lhs) != VAR_DECL
  6160.         && TREE_CODE (lhs) != RESULT_DECL
  6161.         && TREE_CODE (lhs) != PARM_DECL)
  6162.       preexpand_calls (exp);
  6163.  
  6164.     /* Check for |= or &= of a bitfield of size one into another bitfield
  6165.        of size 1.  In this case, (unless we need the result of the
  6166.        assignment) we can do this more efficiently with a
  6167.        test followed by an assignment, if necessary.
  6168.  
  6169.        ??? At this point, we can't get a BIT_FIELD_REF here.  But if
  6170.        things change so we do, this code should be enhanced to
  6171.        support it.  */
  6172.     if (ignore
  6173.         && TREE_CODE (lhs) == COMPONENT_REF
  6174.         && (TREE_CODE (rhs) == BIT_IOR_EXPR
  6175.         || TREE_CODE (rhs) == BIT_AND_EXPR)
  6176.         && TREE_OPERAND (rhs, 0) == lhs
  6177.         && TREE_CODE (TREE_OPERAND (rhs, 1)) == COMPONENT_REF
  6178.         && TREE_INT_CST_LOW (DECL_SIZE (TREE_OPERAND (lhs, 1))) == 1
  6179.         && TREE_INT_CST_LOW (DECL_SIZE (TREE_OPERAND (TREE_OPERAND (rhs, 1), 1))) == 1)
  6180.       {
  6181.         rtx label = gen_label_rtx ();
  6182.  
  6183.         do_jump (TREE_OPERAND (rhs, 1),
  6184.              TREE_CODE (rhs) == BIT_IOR_EXPR ? label : 0,
  6185.              TREE_CODE (rhs) == BIT_AND_EXPR ? label : 0);
  6186.         expand_assignment (lhs, convert (TREE_TYPE (rhs),
  6187.                          (TREE_CODE (rhs) == BIT_IOR_EXPR
  6188.                           ? integer_one_node
  6189.                           : integer_zero_node)),
  6190.                    0, 0);
  6191.         do_pending_stack_adjust ();
  6192.         emit_label (label);
  6193.         return const0_rtx;
  6194.       }
  6195.  
  6196.     if (TYPE_NONCOPIED_PARTS (lhs_type) != 0
  6197.         && ! (fixed_type_p (lhs) && fixed_type_p (rhs)))
  6198.       noncopied_parts = save_noncopied_parts (stabilize_reference (lhs),
  6199.                           TYPE_NONCOPIED_PARTS (lhs_type));
  6200.  
  6201.     temp = expand_assignment (lhs, rhs, ! ignore, original_target != 0);
  6202.     while (noncopied_parts != 0)
  6203.       {
  6204.         expand_assignment (TREE_PURPOSE (noncopied_parts),
  6205.                    TREE_VALUE (noncopied_parts), 0, 0);
  6206.         noncopied_parts = TREE_CHAIN (noncopied_parts);
  6207.       }
  6208.     return temp;
  6209.       }
  6210.  
  6211.     case PREINCREMENT_EXPR:
  6212.     case PREDECREMENT_EXPR:
  6213.       return expand_increment (exp, 0);
  6214.  
  6215.     case POSTINCREMENT_EXPR:
  6216.     case POSTDECREMENT_EXPR:
  6217.       /* Faster to treat as pre-increment if result is not used.  */
  6218.       return expand_increment (exp, ! ignore);
  6219.  
  6220.     case ADDR_EXPR:
  6221.       /* If nonzero, TEMP will be set to the address of something that might
  6222.      be a MEM corresponding to a stack slot. */
  6223.       temp = 0;
  6224.  
  6225.       /* Are we taking the address of a nested function?  */
  6226.       if (TREE_CODE (TREE_OPERAND (exp, 0)) == FUNCTION_DECL
  6227.       && decl_function_context (TREE_OPERAND (exp, 0)) != 0)
  6228.     {
  6229.       op0 = trampoline_address (TREE_OPERAND (exp, 0));
  6230.       op0 = force_operand (op0, target);
  6231.     }
  6232.       /* If we are taking the address of something erroneous, just
  6233.      return a zero.  */
  6234.       else if (TREE_CODE (TREE_OPERAND (exp, 0)) == ERROR_MARK)
  6235.     return const0_rtx;
  6236.       else
  6237.     {
  6238.       /* We make sure to pass const0_rtx down if we came in with
  6239.          ignore set, to avoid doing the cleanups twice for something.  */
  6240.       op0 = expand_expr (TREE_OPERAND (exp, 0),
  6241.                  ignore ? const0_rtx : NULL_RTX, VOIDmode,
  6242.                  (modifier == EXPAND_INITIALIZER
  6243.                   ? modifier : EXPAND_CONST_ADDRESS));
  6244.  
  6245.       /* If we are going to ignore the result, OP0 will have been set
  6246.          to const0_rtx, so just return it.  Don't get confused and
  6247.          think we are taking the address of the constant.  */
  6248.       if (ignore)
  6249.         return op0;
  6250.  
  6251.       /* We would like the object in memory.  If it is a constant,
  6252.          we can have it be statically allocated into memory.  For
  6253.          a non-constant (REG, SUBREG or CONCAT), we need to allocate some
  6254.          memory and store the value into it.  */
  6255.  
  6256.       if (CONSTANT_P (op0))
  6257.         op0 = force_const_mem (TYPE_MODE (TREE_TYPE (TREE_OPERAND (exp, 0))),
  6258.                    op0);
  6259.       else if (GET_CODE (op0) == MEM)
  6260.         {
  6261.           mark_temp_addr_taken (op0);
  6262.           temp = XEXP (op0, 0);
  6263.         }
  6264.  
  6265.       else if (GET_CODE (op0) == REG || GET_CODE (op0) == SUBREG
  6266.            || GET_CODE (op0) == CONCAT)
  6267.         {
  6268.           /* If this object is in a register, it must be not
  6269.          be BLKmode. */
  6270.           tree inner_type = TREE_TYPE (TREE_OPERAND (exp, 0));
  6271.           enum machine_mode inner_mode = TYPE_MODE (inner_type);
  6272.           rtx memloc
  6273.         = assign_stack_temp (inner_mode,
  6274.                      int_size_in_bytes (inner_type), 1);
  6275.           MEM_IN_STRUCT_P (memloc) = AGGREGATE_TYPE_P (inner_type);
  6276.  
  6277.           mark_temp_addr_taken (memloc);
  6278.           emit_move_insn (memloc, op0);
  6279.           op0 = memloc;
  6280.         }
  6281.  
  6282.       if (GET_CODE (op0) != MEM)
  6283.         abort ();
  6284.   
  6285.       if (modifier == EXPAND_SUM || modifier == EXPAND_INITIALIZER)
  6286.         {
  6287.           temp = XEXP (op0, 0);
  6288. #ifdef POINTERS_EXTEND_UNSIGNED
  6289.           if (GET_MODE (temp) == Pmode && GET_MODE (temp) != mode
  6290.           && mode == ptr_mode)
  6291.         temp = convert_memory_address (ptr_mode, temp);
  6292. #endif
  6293.           return temp;
  6294.         }
  6295.  
  6296.       op0 = force_operand (XEXP (op0, 0), target);
  6297.     }
  6298.  
  6299.       if (flag_force_addr && GET_CODE (op0) != REG)
  6300.     op0 = force_reg (Pmode, op0);
  6301.  
  6302.       if (GET_CODE (op0) == REG)
  6303.     mark_reg_pointer (op0);
  6304.  
  6305.       /* If we might have had a temp slot, add an equivalent address
  6306.      for it.  */
  6307.       if (temp != 0)
  6308.     update_temp_slot_address (temp, op0);
  6309.  
  6310. #ifdef POINTERS_EXTEND_UNSIGNED
  6311.       if (GET_MODE (op0) == Pmode && GET_MODE (op0) != mode
  6312.       && mode == ptr_mode)
  6313.     op0 = convert_memory_address (ptr_mode, op0);
  6314. #endif
  6315.  
  6316.       return op0;
  6317.  
  6318.     case ENTRY_VALUE_EXPR:
  6319.       abort ();
  6320.  
  6321.     /* COMPLEX type for Extended Pascal & Fortran  */
  6322.     case COMPLEX_EXPR:
  6323.       {
  6324.     enum machine_mode mode = TYPE_MODE (TREE_TYPE (TREE_TYPE (exp)));
  6325.     rtx insns;
  6326.  
  6327.     /* Get the rtx code of the operands.  */
  6328.     op0 = expand_expr (TREE_OPERAND (exp, 0), 0, VOIDmode, 0);
  6329.     op1 = expand_expr (TREE_OPERAND (exp, 1), 0, VOIDmode, 0);
  6330.  
  6331.     if (! target)
  6332.       target = gen_reg_rtx (TYPE_MODE (TREE_TYPE (exp)));
  6333.  
  6334.     start_sequence ();
  6335.  
  6336.     /* Move the real (op0) and imaginary (op1) parts to their location.  */
  6337.     emit_move_insn (gen_realpart (mode, target), op0);
  6338.     emit_move_insn (gen_imagpart (mode, target), op1);
  6339.  
  6340.     insns = get_insns ();
  6341.     end_sequence ();
  6342.  
  6343.     /* Complex construction should appear as a single unit.  */
  6344.     /* If TARGET is a CONCAT, we got insns like RD = RS, ID = IS,
  6345.        each with a separate pseudo as destination.
  6346.        It's not correct for flow to treat them as a unit.  */
  6347.     if (GET_CODE (target) != CONCAT)
  6348.       emit_no_conflict_block (insns, target, op0, op1, NULL_RTX);
  6349.     else
  6350.       emit_insns (insns);
  6351.  
  6352.     return target;
  6353.       }
  6354.  
  6355.     case REALPART_EXPR:
  6356.       op0 = expand_expr (TREE_OPERAND (exp, 0), 0, VOIDmode, 0);
  6357.       return gen_realpart (mode, op0);
  6358.       
  6359.     case IMAGPART_EXPR:
  6360.       op0 = expand_expr (TREE_OPERAND (exp, 0), 0, VOIDmode, 0);
  6361.       return gen_imagpart (mode, op0);
  6362.  
  6363.     case CONJ_EXPR:
  6364.       {
  6365.     enum machine_mode partmode = TYPE_MODE (TREE_TYPE (TREE_TYPE (exp)));
  6366.     rtx imag_t;
  6367.     rtx insns;
  6368.     
  6369.     op0  = expand_expr (TREE_OPERAND (exp, 0), 0, VOIDmode, 0);
  6370.  
  6371.     if (! target)
  6372.       target = gen_reg_rtx (mode);
  6373.                                     
  6374.     start_sequence ();
  6375.  
  6376.     /* Store the realpart and the negated imagpart to target.  */
  6377.     emit_move_insn (gen_realpart (partmode, target),
  6378.             gen_realpart (partmode, op0));
  6379.  
  6380.     imag_t = gen_imagpart (partmode, target);
  6381.     temp = expand_unop (partmode, neg_optab,
  6382.                    gen_imagpart (partmode, op0), imag_t, 0);
  6383.     if (temp != imag_t)
  6384.       emit_move_insn (imag_t, temp);
  6385.  
  6386.     insns = get_insns ();
  6387.     end_sequence ();
  6388.  
  6389.     /* Conjugate should appear as a single unit 
  6390.        If TARGET is a CONCAT, we got insns like RD = RS, ID = - IS,
  6391.        each with a separate pseudo as destination.
  6392.        It's not correct for flow to treat them as a unit.  */
  6393.     if (GET_CODE (target) != CONCAT)
  6394.       emit_no_conflict_block (insns, target, op0, NULL_RTX, NULL_RTX);
  6395.     else
  6396.       emit_insns (insns);
  6397.  
  6398.     return target;
  6399.       }
  6400.  
  6401.     case ERROR_MARK:
  6402.       op0 = CONST0_RTX (tmode);
  6403.       if (op0 != 0)
  6404.     return op0;
  6405.       return const0_rtx;
  6406.  
  6407.     default:
  6408.       return (*lang_expand_expr) (exp, original_target, tmode, modifier);
  6409.     }
  6410.  
  6411.   /* Here to do an ordinary binary operator, generating an instruction
  6412.      from the optab already placed in `this_optab'.  */
  6413.  binop:
  6414.   preexpand_calls (exp);
  6415.   if (! safe_from_p (subtarget, TREE_OPERAND (exp, 1)))
  6416.     subtarget = 0;
  6417.   op0 = expand_expr (TREE_OPERAND (exp, 0), subtarget, VOIDmode, 0);
  6418.   op1 = expand_expr (TREE_OPERAND (exp, 1), NULL_RTX, VOIDmode, 0);
  6419.  binop2:
  6420.   temp = expand_binop (mode, this_optab, op0, op1, target,
  6421.                unsignedp, OPTAB_LIB_WIDEN);
  6422.   if (temp == 0)
  6423.     abort ();
  6424.   return temp;
  6425. }
  6426.  
  6427.  
  6428. /* Emit bytecode to evaluate the given expression EXP to the stack. */
  6429. void
  6430. bc_expand_expr (exp)
  6431.     tree exp;
  6432. {
  6433.   enum tree_code code;
  6434.   tree type, arg0;
  6435.   rtx r;
  6436.   struct binary_operator *binoptab;
  6437.   struct unary_operator *unoptab;
  6438.   struct increment_operator *incroptab;
  6439.   struct bc_label *lab, *lab1;
  6440.   enum bytecode_opcode opcode;
  6441.   
  6442.   
  6443.   code = TREE_CODE (exp);
  6444.   
  6445.   switch (code)
  6446.     {
  6447.     case PARM_DECL:
  6448.       
  6449.       if (DECL_RTL (exp) == 0)
  6450.     {
  6451.       error_with_decl (exp, "prior parameter's size depends on `%s'");
  6452.       return;
  6453.     }
  6454.       
  6455.       bc_load_parmaddr (DECL_RTL (exp));
  6456.       bc_load_memory (TREE_TYPE (exp), exp);
  6457.       
  6458.       return;
  6459.       
  6460.     case VAR_DECL:
  6461.       
  6462.       if (DECL_RTL (exp) == 0)
  6463.     abort ();
  6464.       
  6465. #if 0
  6466.       if (BYTECODE_LABEL (DECL_RTL (exp)))
  6467.     bc_load_externaddr (DECL_RTL (exp));
  6468.       else
  6469.     bc_load_localaddr (DECL_RTL (exp));
  6470. #endif
  6471.       if (TREE_PUBLIC (exp))
  6472.     bc_load_externaddr_id (DECL_ASSEMBLER_NAME (exp),
  6473.                    BYTECODE_BC_LABEL (DECL_RTL (exp))->offset);
  6474.       else
  6475.     bc_load_localaddr (DECL_RTL (exp));
  6476.       
  6477.       bc_load_memory (TREE_TYPE (exp), exp);
  6478.       return;
  6479.       
  6480.     case INTEGER_CST:
  6481.       
  6482. #ifdef DEBUG_PRINT_CODE
  6483.       fprintf (stderr, " [%x]\n", TREE_INT_CST_LOW (exp));
  6484. #endif
  6485.       bc_emit_instruction (mode_to_const_map[(int) (DECL_BIT_FIELD (exp)
  6486.                          ? SImode
  6487.                          : TYPE_MODE (TREE_TYPE (exp)))],
  6488.                (HOST_WIDE_INT) TREE_INT_CST_LOW (exp));
  6489.       return;
  6490.       
  6491.     case REAL_CST:
  6492.       
  6493. #if 0
  6494. #ifdef DEBUG_PRINT_CODE
  6495.       fprintf (stderr, " [%g]\n", (double) TREE_INT_CST_LOW (exp));
  6496. #endif
  6497.       /* FIX THIS: find a better way to pass real_cst's. -bson */
  6498.       bc_emit_instruction (mode_to_const_map[TYPE_MODE (TREE_TYPE (exp))],
  6499.                (double) TREE_REAL_CST (exp));
  6500. #else
  6501.       abort ();
  6502. #endif
  6503.  
  6504.       return;
  6505.       
  6506.     case CALL_EXPR:
  6507.       
  6508.       /* We build a call description vector describing the type of
  6509.      the return value and of the arguments; this call vector,
  6510.      together with a pointer to a location for the return value
  6511.      and the base of the argument list, is passed to the low
  6512.      level machine dependent call subroutine, which is responsible
  6513.      for putting the arguments wherever real functions expect
  6514.      them, as well as getting the return value back.  */
  6515.       {
  6516.     tree calldesc = 0, arg;
  6517.     int nargs = 0, i;
  6518.     rtx retval;
  6519.     
  6520.     /* Push the evaluated args on the evaluation stack in reverse
  6521.        order.  Also make an entry for each arg in the calldesc
  6522.        vector while we're at it.  */
  6523.     
  6524.     TREE_OPERAND (exp, 1) = nreverse (TREE_OPERAND (exp, 1));
  6525.     
  6526.     for (arg = TREE_OPERAND (exp, 1); arg; arg = TREE_CHAIN (arg))
  6527.       {
  6528.         ++nargs;
  6529.         bc_expand_expr (TREE_VALUE (arg));
  6530.         
  6531.         calldesc = tree_cons ((tree) 0,
  6532.                   size_in_bytes (TREE_TYPE (TREE_VALUE (arg))),
  6533.                   calldesc);
  6534.         calldesc = tree_cons ((tree) 0,
  6535.                   bc_runtime_type_code (TREE_TYPE (TREE_VALUE (arg))),
  6536.                   calldesc);
  6537.       }
  6538.     
  6539.     TREE_OPERAND (exp, 1) = nreverse (TREE_OPERAND (exp, 1));
  6540.     
  6541.     /* Allocate a location for the return value and push its
  6542.        address on the evaluation stack.  Also make an entry
  6543.        at the front of the calldesc for the return value type. */
  6544.     
  6545.     type = TREE_TYPE (TREE_TYPE (TREE_TYPE (TREE_OPERAND (exp, 0))));
  6546.     retval = bc_allocate_local (int_size_in_bytes (type), TYPE_ALIGN (type));
  6547.     bc_load_localaddr (retval);
  6548.     
  6549.     calldesc = tree_cons ((tree) 0, size_in_bytes (type), calldesc);
  6550.     calldesc = tree_cons ((tree) 0, bc_runtime_type_code (type), calldesc);
  6551.     
  6552.     /* Prepend the argument count.  */
  6553.     calldesc = tree_cons ((tree) 0,
  6554.                   build_int_2 (nargs, 0),
  6555.                   calldesc);
  6556.     
  6557.     /* Push the address of the call description vector on the stack.  */
  6558.     calldesc = build_nt (CONSTRUCTOR, (tree) 0, calldesc);
  6559.     TREE_TYPE (calldesc) = build_array_type (integer_type_node,
  6560.                          build_index_type (build_int_2 (nargs * 2, 0)));
  6561.     r = output_constant_def (calldesc);
  6562.     bc_load_externaddr (r);
  6563.     
  6564.     /* Push the address of the function to be called. */
  6565.     bc_expand_expr (TREE_OPERAND (exp, 0));
  6566.     
  6567.     /* Call the function, popping its address and the calldesc vector
  6568.        address off the evaluation stack in the process.  */
  6569.     bc_emit_instruction (call);
  6570.     
  6571.     /* Pop the arguments off the stack.  */
  6572.     bc_adjust_stack (nargs);
  6573.     
  6574.     /* Load the return value onto the stack.  */
  6575.     bc_load_localaddr (retval);
  6576.     bc_load_memory (type, TREE_OPERAND (exp, 0));
  6577.       }
  6578.       return;
  6579.       
  6580.     case SAVE_EXPR:
  6581.       
  6582.       if (!SAVE_EXPR_RTL (exp))
  6583.     {
  6584.       /* First time around: copy to local variable */
  6585.       SAVE_EXPR_RTL (exp) = bc_allocate_local (int_size_in_bytes (TREE_TYPE (exp)),
  6586.                            TYPE_ALIGN (TREE_TYPE(exp)));
  6587.       bc_expand_expr (TREE_OPERAND (exp, 0));
  6588.       bc_emit_instruction (duplicate);
  6589.       
  6590.       bc_load_localaddr (SAVE_EXPR_RTL (exp));
  6591.       bc_store_memory (TREE_TYPE (exp), TREE_OPERAND (exp, 0));
  6592.     }
  6593.       else
  6594.     {
  6595.       /* Consecutive reference: use saved copy */
  6596.       bc_load_localaddr (SAVE_EXPR_RTL (exp));
  6597.       bc_load_memory (TREE_TYPE (exp), TREE_OPERAND (exp, 0));
  6598.     }
  6599.       return;
  6600.       
  6601. #if 0
  6602.       /* FIXME: the XXXX_STMT codes have been removed in GCC2, but
  6603.      how are they handled instead? */
  6604.     case LET_STMT:
  6605.       
  6606.       TREE_USED (exp) = 1;
  6607.       bc_expand_expr (STMT_BODY (exp));
  6608.       return;
  6609. #endif
  6610.       
  6611.     case NOP_EXPR:
  6612.     case CONVERT_EXPR:
  6613.       
  6614.       bc_expand_expr (TREE_OPERAND (exp, 0));
  6615.       bc_expand_conversion (TREE_TYPE (TREE_OPERAND (exp, 0)), TREE_TYPE (exp));
  6616.       return;
  6617.       
  6618.     case MODIFY_EXPR:
  6619.       
  6620.       expand_assignment (TREE_OPERAND (exp, 0), TREE_OPERAND (exp, 1), 0, 0);
  6621.       return;
  6622.       
  6623.     case ADDR_EXPR:
  6624.       
  6625.       bc_expand_address (TREE_OPERAND (exp, 0));
  6626.       return;
  6627.       
  6628.     case INDIRECT_REF:
  6629.       
  6630.       bc_expand_expr (TREE_OPERAND (exp, 0));
  6631.       bc_load_memory (TREE_TYPE (exp), TREE_OPERAND (exp, 0));
  6632.       return;
  6633.       
  6634.     case ARRAY_REF:
  6635.       
  6636.       bc_expand_expr (bc_canonicalize_array_ref (exp));
  6637.       return;
  6638.       
  6639.     case COMPONENT_REF:
  6640.       
  6641.       bc_expand_component_address (exp);
  6642.       
  6643.       /* If we have a bitfield, generate a proper load */
  6644.       bc_load_memory (TREE_TYPE (TREE_OPERAND (exp, 1)), TREE_OPERAND (exp, 1));
  6645.       return;
  6646.       
  6647.     case COMPOUND_EXPR:
  6648.       
  6649.       bc_expand_expr (TREE_OPERAND (exp, 0));
  6650.       bc_emit_instruction (drop);
  6651.       bc_expand_expr (TREE_OPERAND (exp, 1));
  6652.       return;
  6653.       
  6654.     case COND_EXPR:
  6655.       
  6656.       bc_expand_expr (TREE_OPERAND (exp, 0));
  6657.       bc_expand_truth_conversion (TREE_TYPE (TREE_OPERAND (exp, 0)));
  6658.       lab = bc_get_bytecode_label ();
  6659.       bc_emit_bytecode (xjumpifnot);
  6660.       bc_emit_bytecode_labelref (lab);
  6661.       
  6662. #ifdef DEBUG_PRINT_CODE
  6663.       fputc ('\n', stderr);
  6664. #endif
  6665.       bc_expand_expr (TREE_OPERAND (exp, 1));
  6666.       lab1 = bc_get_bytecode_label ();
  6667.       bc_emit_bytecode (jump);
  6668.       bc_emit_bytecode_labelref (lab1);
  6669.       
  6670. #ifdef DEBUG_PRINT_CODE
  6671.       fputc ('\n', stderr);
  6672. #endif
  6673.       
  6674.       bc_emit_bytecode_labeldef (lab);
  6675.       bc_expand_expr (TREE_OPERAND (exp, 2));
  6676.       bc_emit_bytecode_labeldef (lab1);
  6677.       return;
  6678.       
  6679.     case TRUTH_ANDIF_EXPR:
  6680.       
  6681.       opcode = xjumpifnot;
  6682.       goto andorif;
  6683.       
  6684.     case TRUTH_ORIF_EXPR:
  6685.       
  6686.       opcode = xjumpif;
  6687.       goto andorif;
  6688.       
  6689.     case PLUS_EXPR:
  6690.       
  6691.       binoptab = optab_plus_expr;
  6692.       goto binop;
  6693.       
  6694.     case MINUS_EXPR:
  6695.       
  6696.       binoptab = optab_minus_expr;
  6697.       goto binop;
  6698.       
  6699.     case MULT_EXPR:
  6700.       
  6701.       binoptab = optab_mult_expr;
  6702.       goto binop;
  6703.       
  6704.     case TRUNC_DIV_EXPR:
  6705.     case FLOOR_DIV_EXPR:
  6706.     case CEIL_DIV_EXPR:
  6707.     case ROUND_DIV_EXPR:
  6708.     case EXACT_DIV_EXPR:
  6709.       
  6710.       binoptab = optab_trunc_div_expr;
  6711.       goto binop;
  6712.       
  6713.     case TRUNC_MOD_EXPR:
  6714.     case FLOOR_MOD_EXPR:
  6715.     case CEIL_MOD_EXPR:
  6716.     case ROUND_MOD_EXPR:
  6717.       
  6718.       binoptab = optab_trunc_mod_expr;
  6719.       goto binop;
  6720.       
  6721.     case FIX_ROUND_EXPR:
  6722.     case FIX_FLOOR_EXPR:
  6723.     case FIX_CEIL_EXPR:
  6724.       abort ();            /* Not used for C.  */
  6725.       
  6726.     case FIX_TRUNC_EXPR:
  6727.     case FLOAT_EXPR:
  6728.     case MAX_EXPR:
  6729.     case MIN_EXPR:
  6730.     case FFS_EXPR:
  6731.     case LROTATE_EXPR:
  6732.     case RROTATE_EXPR:
  6733.       abort ();            /* FIXME */
  6734.       
  6735.     case RDIV_EXPR:
  6736.       
  6737.       binoptab = optab_rdiv_expr;
  6738.       goto binop;
  6739.       
  6740.     case BIT_AND_EXPR:
  6741.       
  6742.       binoptab = optab_bit_and_expr;
  6743.       goto binop;
  6744.       
  6745.     case BIT_IOR_EXPR:
  6746.       
  6747.       binoptab = optab_bit_ior_expr;
  6748.       goto binop;
  6749.       
  6750.     case BIT_XOR_EXPR:
  6751.       
  6752.       binoptab = optab_bit_xor_expr;
  6753.       goto binop;
  6754.       
  6755.     case LSHIFT_EXPR:
  6756.       
  6757.       binoptab = optab_lshift_expr;
  6758.       goto binop;
  6759.       
  6760.     case RSHIFT_EXPR:
  6761.       
  6762.       binoptab = optab_rshift_expr;
  6763.       goto binop;
  6764.       
  6765.     case TRUTH_AND_EXPR:
  6766.       
  6767.       binoptab = optab_truth_and_expr;
  6768.       goto binop;
  6769.       
  6770.     case TRUTH_OR_EXPR:
  6771.       
  6772.       binoptab = optab_truth_or_expr;
  6773.       goto binop;
  6774.       
  6775.     case LT_EXPR:
  6776.       
  6777.       binoptab = optab_lt_expr;
  6778.       goto binop;
  6779.       
  6780.     case LE_EXPR:
  6781.       
  6782.       binoptab = optab_le_expr;
  6783.       goto binop;
  6784.       
  6785.     case GE_EXPR:
  6786.       
  6787.       binoptab = optab_ge_expr;
  6788.       goto binop;
  6789.       
  6790.     case GT_EXPR:
  6791.       
  6792.       binoptab = optab_gt_expr;
  6793.       goto binop;
  6794.       
  6795.     case EQ_EXPR:
  6796.       
  6797.       binoptab = optab_eq_expr;
  6798.       goto binop;
  6799.       
  6800.     case NE_EXPR:
  6801.       
  6802.       binoptab = optab_ne_expr;
  6803.       goto binop;
  6804.       
  6805.     case NEGATE_EXPR:
  6806.       
  6807.       unoptab = optab_negate_expr;
  6808.       goto unop;
  6809.       
  6810.     case BIT_NOT_EXPR:
  6811.       
  6812.       unoptab = optab_bit_not_expr;
  6813.       goto unop;
  6814.       
  6815.     case TRUTH_NOT_EXPR:
  6816.       
  6817.       unoptab = optab_truth_not_expr;
  6818.       goto unop;
  6819.       
  6820.     case PREDECREMENT_EXPR:
  6821.       
  6822.       incroptab = optab_predecrement_expr;
  6823.       goto increment;
  6824.       
  6825.     case PREINCREMENT_EXPR:
  6826.       
  6827.       incroptab = optab_preincrement_expr;
  6828.       goto increment;
  6829.       
  6830.     case POSTDECREMENT_EXPR:
  6831.       
  6832.       incroptab = optab_postdecrement_expr;
  6833.       goto increment;
  6834.       
  6835.     case POSTINCREMENT_EXPR:
  6836.       
  6837.       incroptab = optab_postincrement_expr;
  6838.       goto increment;
  6839.       
  6840.     case CONSTRUCTOR:
  6841.       
  6842.       bc_expand_constructor (exp);
  6843.       return;
  6844.       
  6845.     case ERROR_MARK:
  6846.     case RTL_EXPR:
  6847.       
  6848.       return;
  6849.       
  6850.     case BIND_EXPR:
  6851.       {
  6852.     tree vars = TREE_OPERAND (exp, 0);
  6853.     int vars_need_expansion = 0;
  6854.     
  6855.     /* Need to open a binding contour here because
  6856.        if there are any cleanups they most be contained here.  */
  6857.     expand_start_bindings (0);
  6858.     
  6859.     /* Mark the corresponding BLOCK for output.  */
  6860.     if (TREE_OPERAND (exp, 2) != 0)
  6861.       TREE_USED (TREE_OPERAND (exp, 2)) = 1;
  6862.     
  6863.     /* If VARS have not yet been expanded, expand them now.  */
  6864.     while (vars)
  6865.       {
  6866.         if (DECL_RTL (vars) == 0)
  6867.           {
  6868.         vars_need_expansion = 1;
  6869.         expand_decl (vars);
  6870.           }
  6871.         expand_decl_init (vars);
  6872.         vars = TREE_CHAIN (vars);
  6873.       }
  6874.     
  6875.     bc_expand_expr (TREE_OPERAND (exp, 1));
  6876.     
  6877.     expand_end_bindings (TREE_OPERAND (exp, 0), 0, 0);
  6878.     
  6879.     return;
  6880.       }
  6881.     }
  6882.   
  6883.   abort ();
  6884.   
  6885.  binop:
  6886.   
  6887.   bc_expand_binary_operation (binoptab, TREE_TYPE (exp),
  6888.                   TREE_OPERAND (exp, 0), TREE_OPERAND (exp, 1));
  6889.   return;
  6890.   
  6891.   
  6892.  unop:
  6893.   
  6894.   bc_expand_unary_operation (unoptab, TREE_TYPE (exp), TREE_OPERAND (exp, 0));
  6895.   return;
  6896.   
  6897.   
  6898.  andorif:
  6899.   
  6900.   bc_expand_expr (TREE_OPERAND (exp, 0));
  6901.   bc_expand_truth_conversion (TREE_TYPE (TREE_OPERAND (exp, 0)));
  6902.   lab = bc_get_bytecode_label ();
  6903.   
  6904.   bc_emit_instruction (duplicate);
  6905.   bc_emit_bytecode (opcode);
  6906.   bc_emit_bytecode_labelref (lab);
  6907.   
  6908. #ifdef DEBUG_PRINT_CODE
  6909.   fputc ('\n', stderr);
  6910. #endif
  6911.   
  6912.   bc_emit_instruction (drop);
  6913.   
  6914.   bc_expand_expr (TREE_OPERAND (exp, 1));
  6915.   bc_expand_truth_conversion (TREE_TYPE (TREE_OPERAND (exp, 1)));
  6916.   bc_emit_bytecode_labeldef (lab);
  6917.   return;
  6918.   
  6919.   
  6920.  increment:
  6921.   
  6922.   type = TREE_TYPE (TREE_OPERAND (exp, 0));
  6923.   
  6924.   /* Push the quantum.  */
  6925.   bc_expand_expr (TREE_OPERAND (exp, 1));
  6926.   
  6927.   /* Convert it to the lvalue's type.  */
  6928.   bc_expand_conversion (TREE_TYPE (TREE_OPERAND (exp, 1)), type);
  6929.   
  6930.   /* Push the address of the lvalue */
  6931.   bc_expand_expr (build1 (ADDR_EXPR, TYPE_POINTER_TO (type), TREE_OPERAND (exp, 0)));
  6932.   
  6933.   /* Perform actual increment */
  6934.   bc_expand_increment (incroptab, type);
  6935.   return;
  6936. }
  6937.  
  6938. /* Return the alignment in bits of EXP, a pointer valued expression.
  6939.    But don't return more than MAX_ALIGN no matter what.
  6940.    The alignment returned is, by default, the alignment of the thing that
  6941.    EXP points to (if it is not a POINTER_TYPE, 0 is returned).
  6942.  
  6943.    Otherwise, look at the expression to see if we can do better, i.e., if the
  6944.    expression is actually pointing at an object whose alignment is tighter.  */
  6945.  
  6946. static int
  6947. get_pointer_alignment (exp, max_align)
  6948.      tree exp;
  6949.      unsigned max_align;
  6950. {
  6951.   unsigned align, inner;
  6952.  
  6953.   if (TREE_CODE (TREE_TYPE (exp)) != POINTER_TYPE)
  6954.     return 0;
  6955.  
  6956.   align = TYPE_ALIGN (TREE_TYPE (TREE_TYPE (exp)));
  6957.   align = MIN (align, max_align);
  6958.  
  6959.   while (1)
  6960.     {
  6961.       switch (TREE_CODE (exp))
  6962.     {
  6963.     case NOP_EXPR:
  6964.     case CONVERT_EXPR:
  6965.     case NON_LVALUE_EXPR:
  6966.       exp = TREE_OPERAND (exp, 0);
  6967.       if (TREE_CODE (TREE_TYPE (exp)) != POINTER_TYPE)
  6968.         return align;
  6969.       inner = TYPE_ALIGN (TREE_TYPE (TREE_TYPE (exp)));
  6970.       align = MIN (inner, max_align);
  6971.       break;
  6972.  
  6973.     case PLUS_EXPR:
  6974.       /* If sum of pointer + int, restrict our maximum alignment to that
  6975.          imposed by the integer.  If not, we can't do any better than
  6976.          ALIGN.  */
  6977.       if (TREE_CODE (TREE_OPERAND (exp, 1)) != INTEGER_CST)
  6978.         return align;
  6979.  
  6980.       while (((TREE_INT_CST_LOW (TREE_OPERAND (exp, 1)) * BITS_PER_UNIT)
  6981.           & (max_align - 1))
  6982.          != 0)
  6983.         max_align >>= 1;
  6984.  
  6985.       exp = TREE_OPERAND (exp, 0);
  6986.       break;
  6987.  
  6988.     case ADDR_EXPR:
  6989.       /* See what we are pointing at and look at its alignment.  */
  6990.       exp = TREE_OPERAND (exp, 0);
  6991.       if (TREE_CODE (exp) == FUNCTION_DECL)
  6992.         align = FUNCTION_BOUNDARY;
  6993.       else if (TREE_CODE_CLASS (TREE_CODE (exp)) == 'd')
  6994.         align = DECL_ALIGN (exp);
  6995. #ifdef CONSTANT_ALIGNMENT
  6996.       else if (TREE_CODE_CLASS (TREE_CODE (exp)) == 'c')
  6997.         align = CONSTANT_ALIGNMENT (exp, align);
  6998. #endif
  6999.       return MIN (align, max_align);
  7000.  
  7001.     default:
  7002.       return align;
  7003.     }
  7004.     }
  7005. }
  7006.  
  7007. /* Return the tree node and offset if a given argument corresponds to
  7008.    a string constant.  */
  7009.  
  7010. static tree
  7011. string_constant (arg, ptr_offset)
  7012.      tree arg;
  7013.      tree *ptr_offset;
  7014. {
  7015.   STRIP_NOPS (arg);
  7016.  
  7017.   if (TREE_CODE (arg) == ADDR_EXPR
  7018.       && TREE_CODE (TREE_OPERAND (arg, 0)) == STRING_CST)
  7019.     {
  7020.       *ptr_offset = integer_zero_node;
  7021.       return TREE_OPERAND (arg, 0);
  7022.     }
  7023.   else if (TREE_CODE (arg) == PLUS_EXPR)
  7024.     {
  7025.       tree arg0 = TREE_OPERAND (arg, 0);
  7026.       tree arg1 = TREE_OPERAND (arg, 1);
  7027.  
  7028.       STRIP_NOPS (arg0);
  7029.       STRIP_NOPS (arg1);
  7030.  
  7031.       if (TREE_CODE (arg0) == ADDR_EXPR
  7032.       && TREE_CODE (TREE_OPERAND (arg0, 0)) == STRING_CST)
  7033.     {
  7034.       *ptr_offset = arg1;
  7035.       return TREE_OPERAND (arg0, 0);
  7036.     }
  7037.       else if (TREE_CODE (arg1) == ADDR_EXPR
  7038.            && TREE_CODE (TREE_OPERAND (arg1, 0)) == STRING_CST)
  7039.     {
  7040.       *ptr_offset = arg0;
  7041.       return TREE_OPERAND (arg1, 0);
  7042.     }
  7043.     }
  7044.  
  7045.   return 0;
  7046. }
  7047.  
  7048. /* Compute the length of a C string.  TREE_STRING_LENGTH is not the right
  7049.    way, because it could contain a zero byte in the middle.
  7050.    TREE_STRING_LENGTH is the size of the character array, not the string.
  7051.  
  7052.    Unfortunately, string_constant can't access the values of const char
  7053.    arrays with initializers, so neither can we do so here.  */
  7054.  
  7055. static tree
  7056. c_strlen (src)
  7057.      tree src;
  7058. {
  7059.   tree offset_node;
  7060.   int offset, max;
  7061.   char *ptr;
  7062.  
  7063.   src = string_constant (src, &offset_node);
  7064.   if (src == 0)
  7065.     return 0;
  7066.   max = TREE_STRING_LENGTH (src);
  7067.   ptr = TREE_STRING_POINTER (src);
  7068.   if (offset_node && TREE_CODE (offset_node) != INTEGER_CST)
  7069.     {
  7070.       /* If the string has an internal zero byte (e.g., "foo\0bar"), we can't
  7071.      compute the offset to the following null if we don't know where to
  7072.      start searching for it.  */
  7073.       int i;
  7074.       for (i = 0; i < max; i++)
  7075.     if (ptr[i] == 0)
  7076.       return 0;
  7077.       /* We don't know the starting offset, but we do know that the string
  7078.      has no internal zero bytes.  We can assume that the offset falls
  7079.      within the bounds of the string; otherwise, the programmer deserves
  7080.      what he gets.  Subtract the offset from the length of the string,
  7081.      and return that.  */
  7082.       /* This would perhaps not be valid if we were dealing with named
  7083.          arrays in addition to literal string constants.  */
  7084.       return size_binop (MINUS_EXPR, size_int (max), offset_node);
  7085.     }
  7086.  
  7087.   /* We have a known offset into the string.  Start searching there for
  7088.      a null character.  */
  7089.   if (offset_node == 0)
  7090.     offset = 0;
  7091.   else
  7092.     {
  7093.       /* Did we get a long long offset?  If so, punt.  */
  7094.       if (TREE_INT_CST_HIGH (offset_node) != 0)
  7095.     return 0;
  7096.       offset = TREE_INT_CST_LOW (offset_node);
  7097.     }
  7098.   /* If the offset is known to be out of bounds, warn, and call strlen at
  7099.      runtime.  */
  7100.   if (offset < 0 || offset > max)
  7101.     {
  7102.       warning ("offset outside bounds of constant string");
  7103.       return 0;
  7104.     }
  7105.   /* Use strlen to search for the first zero byte.  Since any strings
  7106.      constructed with build_string will have nulls appended, we win even
  7107.      if we get handed something like (char[4])"abcd".
  7108.  
  7109.      Since OFFSET is our starting index into the string, no further
  7110.      calculation is needed.  */
  7111.   return size_int (strlen (ptr + offset));
  7112. }
  7113.  
  7114. /* Expand an expression EXP that calls a built-in function,
  7115.    with result going to TARGET if that's convenient
  7116.    (and in mode MODE if that's convenient).
  7117.    SUBTARGET may be used as the target for computing one of EXP's operands.
  7118.    IGNORE is nonzero if the value is to be ignored.  */
  7119.  
  7120. #define CALLED_AS_BUILT_IN(NODE) \
  7121.    (!strncmp (IDENTIFIER_POINTER (DECL_NAME (NODE)), "__builtin_", 10))
  7122.  
  7123. static rtx
  7124. expand_builtin (exp, target, subtarget, mode, ignore)
  7125.      tree exp;
  7126.      rtx target;
  7127.      rtx subtarget;
  7128.      enum machine_mode mode;
  7129.      int ignore;
  7130. {
  7131.   tree fndecl = TREE_OPERAND (TREE_OPERAND (exp, 0), 0);
  7132.   tree arglist = TREE_OPERAND (exp, 1);
  7133.   rtx op0;
  7134.   rtx lab1, insns;
  7135.   enum machine_mode value_mode = TYPE_MODE (TREE_TYPE (exp));
  7136.   optab builtin_optab;
  7137.  
  7138.   switch (DECL_FUNCTION_CODE (fndecl))
  7139.     {
  7140.     case BUILT_IN_ABS:
  7141.     case BUILT_IN_LABS:
  7142.     case BUILT_IN_FABS:
  7143.       /* build_function_call changes these into ABS_EXPR.  */
  7144.       abort ();
  7145.  
  7146.     case BUILT_IN_SIN:
  7147.     case BUILT_IN_COS:
  7148.       /* Treat these like sqrt, but only if the user asks for them. */
  7149.       if (! flag_fast_math)
  7150.     break;
  7151.     case BUILT_IN_FSQRT:
  7152.       /* If not optimizing, call the library function.  */
  7153.       if (! optimize)
  7154.     break;
  7155.  
  7156.       if (arglist == 0
  7157.       /* Arg could be wrong type if user redeclared this fcn wrong.  */
  7158.       || TREE_CODE (TREE_TYPE (TREE_VALUE (arglist))) != REAL_TYPE)
  7159.     break;
  7160.  
  7161.       /* Stabilize and compute the argument.  */
  7162.       if (TREE_CODE (TREE_VALUE (arglist)) != VAR_DECL
  7163.       && TREE_CODE (TREE_VALUE (arglist)) != PARM_DECL)
  7164.     {
  7165.       exp = copy_node (exp);
  7166.       arglist = copy_node (arglist);
  7167.       TREE_OPERAND (exp, 1) = arglist;
  7168.       TREE_VALUE (arglist) = save_expr (TREE_VALUE (arglist));
  7169.     }
  7170.       op0 = expand_expr (TREE_VALUE (arglist), subtarget, VOIDmode, 0);
  7171.  
  7172.       /* Make a suitable register to place result in.  */
  7173.       target = gen_reg_rtx (TYPE_MODE (TREE_TYPE (exp)));
  7174.  
  7175.       emit_queue ();
  7176.       start_sequence ();
  7177.  
  7178.       switch (DECL_FUNCTION_CODE (fndecl))
  7179.     {
  7180.     case BUILT_IN_SIN:
  7181.       builtin_optab = sin_optab; break;
  7182.     case BUILT_IN_COS:
  7183.       builtin_optab = cos_optab; break;
  7184.     case BUILT_IN_FSQRT:
  7185.       builtin_optab = sqrt_optab; break;
  7186.     default:
  7187.       abort ();
  7188.     }
  7189.  
  7190.       /* Compute into TARGET.
  7191.      Set TARGET to wherever the result comes back.  */
  7192.       target = expand_unop (TYPE_MODE (TREE_TYPE (TREE_VALUE (arglist))),
  7193.                 builtin_optab, op0, target, 0);
  7194.  
  7195.       /* If we were unable to expand via the builtin, stop the
  7196.      sequence (without outputting the insns) and break, causing
  7197.      a call the the library function.  */
  7198.       if (target == 0)
  7199.     {
  7200.       end_sequence ();
  7201.       break;
  7202.         }
  7203.  
  7204.       /* Check the results by default.  But if flag_fast_math is turned on,
  7205.      then assume sqrt will always be called with valid arguments.  */
  7206.  
  7207.       if (! flag_fast_math)
  7208.     {
  7209.       /* Don't define the builtin FP instructions
  7210.          if your machine is not IEEE.  */
  7211.       if (TARGET_FLOAT_FORMAT != IEEE_FLOAT_FORMAT)
  7212.         abort ();
  7213.  
  7214.       lab1 = gen_label_rtx ();
  7215.  
  7216.       /* Test the result; if it is NaN, set errno=EDOM because
  7217.          the argument was not in the domain.  */
  7218.       emit_cmp_insn (target, target, EQ, 0, GET_MODE (target), 0, 0);
  7219.       emit_jump_insn (gen_beq (lab1));
  7220.  
  7221. #ifdef TARGET_EDOM
  7222.       {
  7223. #ifdef GEN_ERRNO_RTX
  7224.         rtx errno_rtx = GEN_ERRNO_RTX;
  7225. #else
  7226.         rtx errno_rtx
  7227.           = gen_rtx (MEM, word_mode, gen_rtx (SYMBOL_REF, Pmode, "errno"));
  7228. #endif
  7229.  
  7230.         emit_move_insn (errno_rtx, GEN_INT (TARGET_EDOM));
  7231.       }
  7232. #else
  7233.       /* We can't set errno=EDOM directly; let the library call do it.
  7234.          Pop the arguments right away in case the call gets deleted. */
  7235.       NO_DEFER_POP;
  7236.       expand_call (exp, target, 0);
  7237.       OK_DEFER_POP;
  7238. #endif
  7239.  
  7240.       emit_label (lab1);
  7241.     }
  7242.  
  7243.       /* Output the entire sequence. */
  7244.       insns = get_insns ();
  7245.       end_sequence ();
  7246.       emit_insns (insns);
  7247.  
  7248.       return target;
  7249.  
  7250.       /* __builtin_apply_args returns block of memory allocated on
  7251.      the stack into which is stored the arg pointer, structure
  7252.      value address, static chain, and all the registers that might
  7253.      possibly be used in performing a function call.  The code is
  7254.      moved to the start of the function so the incoming values are
  7255.      saved.  */
  7256.     case BUILT_IN_APPLY_ARGS:
  7257.       /* Don't do __builtin_apply_args more than once in a function.
  7258.      Save the result of the first call and reuse it.  */
  7259.       if (apply_args_value != 0)
  7260.     return apply_args_value;
  7261.       {
  7262.     /* When this function is called, it means that registers must be
  7263.        saved on entry to this function.  So we migrate the
  7264.        call to the first insn of this function.  */
  7265.     rtx temp;
  7266.     rtx seq;
  7267.  
  7268.     start_sequence ();
  7269.     temp = expand_builtin_apply_args ();
  7270.     seq = get_insns ();
  7271.     end_sequence ();
  7272.  
  7273.     apply_args_value = temp;
  7274.  
  7275.     /* Put the sequence after the NOTE that starts the function.
  7276.        If this is inside a SEQUENCE, make the outer-level insn
  7277.        chain current, so the code is placed at the start of the
  7278.        function.  */
  7279.     push_topmost_sequence ();
  7280.     emit_insns_before (seq, NEXT_INSN (get_insns ()));
  7281.     pop_topmost_sequence ();
  7282.     return temp;
  7283.       }
  7284.  
  7285.       /* __builtin_apply (FUNCTION, ARGUMENTS, ARGSIZE) invokes
  7286.      FUNCTION with a copy of the parameters described by
  7287.      ARGUMENTS, and ARGSIZE.  It returns a block of memory
  7288.      allocated on the stack into which is stored all the registers
  7289.      that might possibly be used for returning the result of a
  7290.      function.  ARGUMENTS is the value returned by
  7291.      __builtin_apply_args.  ARGSIZE is the number of bytes of
  7292.      arguments that must be copied.  ??? How should this value be
  7293.      computed?  We'll also need a safe worst case value for varargs
  7294.      functions.  */
  7295.     case BUILT_IN_APPLY:
  7296.       if (arglist == 0
  7297.       /* Arg could be non-pointer if user redeclared this fcn wrong.  */
  7298.       || TREE_CODE (TREE_TYPE (TREE_VALUE (arglist))) != POINTER_TYPE
  7299.       || TREE_CHAIN (arglist) == 0
  7300.       || TREE_CODE (TREE_TYPE (TREE_VALUE (TREE_CHAIN (arglist)))) != POINTER_TYPE
  7301.       || TREE_CHAIN (TREE_CHAIN (arglist)) == 0
  7302.       || TREE_CODE (TREE_TYPE (TREE_VALUE (TREE_CHAIN (TREE_CHAIN (arglist))))) != INTEGER_TYPE)
  7303.     return const0_rtx;
  7304.       else
  7305.     {
  7306.       int i;
  7307.       tree t;
  7308.       rtx ops[3];
  7309.  
  7310.       for (t = arglist, i = 0; t; t = TREE_CHAIN (t), i++)
  7311.         ops[i] = expand_expr (TREE_VALUE (t), NULL_RTX, VOIDmode, 0);
  7312.  
  7313.       return expand_builtin_apply (ops[0], ops[1], ops[2]);
  7314.     }
  7315.  
  7316.       /* __builtin_return (RESULT) causes the function to return the
  7317.      value described by RESULT.  RESULT is address of the block of
  7318.      memory returned by __builtin_apply.  */
  7319.     case BUILT_IN_RETURN:
  7320.       if (arglist
  7321.       /* Arg could be non-pointer if user redeclared this fcn wrong.  */
  7322.       && TREE_CODE (TREE_TYPE (TREE_VALUE (arglist))) == POINTER_TYPE)
  7323.     expand_builtin_return (expand_expr (TREE_VALUE (arglist),
  7324.                         NULL_RTX, VOIDmode, 0));
  7325.       return const0_rtx;
  7326.  
  7327.     case BUILT_IN_SAVEREGS:
  7328.       /* Don't do __builtin_saveregs more than once in a function.
  7329.      Save the result of the first call and reuse it.  */
  7330.       if (saveregs_value != 0)
  7331.     return saveregs_value;
  7332.       {
  7333.     /* When this function is called, it means that registers must be
  7334.        saved on entry to this function.  So we migrate the
  7335.        call to the first insn of this function.  */
  7336.     rtx temp;
  7337.     rtx seq;
  7338.  
  7339.     /* Now really call the function.  `expand_call' does not call
  7340.        expand_builtin, so there is no danger of infinite recursion here.  */
  7341.     start_sequence ();
  7342.  
  7343. #ifdef EXPAND_BUILTIN_SAVEREGS
  7344.     /* Do whatever the machine needs done in this case.  */
  7345.     temp = EXPAND_BUILTIN_SAVEREGS (arglist);
  7346. #else
  7347.     /* The register where the function returns its value
  7348.        is likely to have something else in it, such as an argument.
  7349.        So preserve that register around the call.  */
  7350.  
  7351.     if (value_mode != VOIDmode)
  7352.       {
  7353.         rtx valreg = hard_libcall_value (value_mode);
  7354.         rtx saved_valreg = gen_reg_rtx (value_mode);
  7355.  
  7356.         emit_move_insn (saved_valreg, valreg);
  7357.         temp = expand_call (exp, target, ignore);
  7358.         emit_move_insn (valreg, saved_valreg);
  7359.       }
  7360.     else
  7361.       /* Generate the call, putting the value in a pseudo.  */
  7362.       temp = expand_call (exp, target, ignore);
  7363. #endif
  7364.  
  7365.     seq = get_insns ();
  7366.     end_sequence ();
  7367.  
  7368.     saveregs_value = temp;
  7369.  
  7370.     /* Put the sequence after the NOTE that starts the function.
  7371.        If this is inside a SEQUENCE, make the outer-level insn
  7372.        chain current, so the code is placed at the start of the
  7373.        function.  */
  7374.     push_topmost_sequence ();
  7375.     emit_insns_before (seq, NEXT_INSN (get_insns ()));
  7376.     pop_topmost_sequence ();
  7377.     return temp;
  7378.       }
  7379.  
  7380.       /* __builtin_args_info (N) returns word N of the arg space info
  7381.      for the current function.  The number and meanings of words
  7382.      is controlled by the definition of CUMULATIVE_ARGS.  */
  7383.     case BUILT_IN_ARGS_INFO:
  7384.       {
  7385.     int nwords = sizeof (CUMULATIVE_ARGS) / sizeof (int);
  7386.     int i;
  7387.     int *word_ptr = (int *) ¤t_function_args_info;
  7388.     tree type, elts, result;
  7389.  
  7390.     if (sizeof (CUMULATIVE_ARGS) % sizeof (int) != 0)
  7391.       fatal ("CUMULATIVE_ARGS type defined badly; see %s, line %d",
  7392.          __FILE__, __LINE__);
  7393.  
  7394.     if (arglist != 0)
  7395.       {
  7396.         tree arg = TREE_VALUE (arglist);
  7397.         if (TREE_CODE (arg) != INTEGER_CST)
  7398.           error ("argument of `__builtin_args_info' must be constant");
  7399.         else
  7400.           {
  7401.         int wordnum = TREE_INT_CST_LOW (arg);
  7402.  
  7403.         if (wordnum < 0 || wordnum >= nwords || TREE_INT_CST_HIGH (arg))
  7404.           error ("argument of `__builtin_args_info' out of range");
  7405.         else
  7406.           return GEN_INT (word_ptr[wordnum]);
  7407.           }
  7408.       }
  7409.     else
  7410.       error ("missing argument in `__builtin_args_info'");
  7411.  
  7412.     return const0_rtx;
  7413.  
  7414. #if 0
  7415.     for (i = 0; i < nwords; i++)
  7416.       elts = tree_cons (NULL_TREE, build_int_2 (word_ptr[i], 0));
  7417.  
  7418.     type = build_array_type (integer_type_node,
  7419.                  build_index_type (build_int_2 (nwords, 0)));
  7420.     result = build (CONSTRUCTOR, type, NULL_TREE, nreverse (elts));
  7421.     TREE_CONSTANT (result) = 1;
  7422.     TREE_STATIC (result) = 1;
  7423.     result = build (INDIRECT_REF, build_pointer_type (type), result);
  7424.     TREE_CONSTANT (result) = 1;
  7425.     return expand_expr (result, NULL_RTX, VOIDmode, 0);
  7426. #endif
  7427.       }
  7428.  
  7429.       /* Return the address of the first anonymous stack arg.  */
  7430.     case BUILT_IN_NEXT_ARG:
  7431.       {
  7432.     tree fntype = TREE_TYPE (current_function_decl);
  7433.  
  7434.     if ((TYPE_ARG_TYPES (fntype) == 0
  7435.          || (TREE_VALUE (tree_last (TYPE_ARG_TYPES (fntype)))
  7436.          == void_type_node))
  7437.         && ! current_function_varargs)
  7438.       {
  7439.         error ("`va_start' used in function with fixed args");
  7440.         return const0_rtx;
  7441.       }
  7442.  
  7443.     if (arglist)
  7444.       {
  7445.         tree last_parm = tree_last (DECL_ARGUMENTS (current_function_decl));
  7446.         tree arg = TREE_VALUE (arglist);
  7447.  
  7448.         /* Strip off all nops for the sake of the comparison.  This
  7449.            is not quite the same as STRIP_NOPS.  It does more.  */
  7450.         while (TREE_CODE (arg) == NOP_EXPR
  7451.            || TREE_CODE (arg) == CONVERT_EXPR
  7452.            || TREE_CODE (arg) == NON_LVALUE_EXPR)
  7453.           arg = TREE_OPERAND (arg, 0);
  7454.         if (arg != last_parm)
  7455.           warning ("second parameter of `va_start' not last named argument");
  7456.       }
  7457.     else if (! current_function_varargs)
  7458.       /* Evidently an out of date version of <stdarg.h>; can't validate
  7459.          va_start's second argument, but can still work as intended.  */
  7460.       warning ("`__builtin_next_arg' called without an argument");
  7461.       }
  7462.  
  7463.       return expand_binop (Pmode, add_optab,
  7464.                current_function_internal_arg_pointer,
  7465.                current_function_arg_offset_rtx,
  7466.                NULL_RTX, 0, OPTAB_LIB_WIDEN);
  7467.  
  7468.     case BUILT_IN_CLASSIFY_TYPE:
  7469.       if (arglist != 0)
  7470.     {
  7471.       tree type = TREE_TYPE (TREE_VALUE (arglist));
  7472.       enum tree_code code = TREE_CODE (type);
  7473.       if (code == VOID_TYPE)
  7474.         return GEN_INT (void_type_class);
  7475.       if (code == INTEGER_TYPE)
  7476.         return GEN_INT (integer_type_class);
  7477.       if (code == CHAR_TYPE)
  7478.         return GEN_INT (char_type_class);
  7479.       if (code == ENUMERAL_TYPE)
  7480.         return GEN_INT (enumeral_type_class);
  7481.       if (code == BOOLEAN_TYPE)
  7482.         return GEN_INT (boolean_type_class);
  7483.       if (code == POINTER_TYPE)
  7484.         return GEN_INT (pointer_type_class);
  7485.       if (code == REFERENCE_TYPE)
  7486.         return GEN_INT (reference_type_class);
  7487.       if (code == OFFSET_TYPE)
  7488.         return GEN_INT (offset_type_class);
  7489.       if (code == REAL_TYPE)
  7490.         return GEN_INT (real_type_class);
  7491.       if (code == COMPLEX_TYPE)
  7492.         return GEN_INT (complex_type_class);
  7493.       if (code == FUNCTION_TYPE)
  7494.         return GEN_INT (function_type_class);
  7495.       if (code == METHOD_TYPE)
  7496.         return GEN_INT (method_type_class);
  7497.       if (code == RECORD_TYPE)
  7498.         return GEN_INT (record_type_class);
  7499.       if (code == UNION_TYPE || code == QUAL_UNION_TYPE)
  7500.         return GEN_INT (union_type_class);
  7501.       if (code == ARRAY_TYPE)
  7502.         {
  7503.           if (TYPE_STRING_FLAG (type))
  7504.         return GEN_INT (string_type_class);
  7505.           else
  7506.         return GEN_INT (array_type_class);
  7507.         }
  7508.       if (code == SET_TYPE)
  7509.         return GEN_INT (set_type_class);
  7510.       if (code == FILE_TYPE)
  7511.         return GEN_INT (file_type_class);
  7512.       if (code == LANG_TYPE)
  7513.         return GEN_INT (lang_type_class);
  7514.     }
  7515.       return GEN_INT (no_type_class);
  7516.  
  7517.     case BUILT_IN_CONSTANT_P:
  7518.       if (arglist == 0)
  7519.     return const0_rtx;
  7520.       else
  7521.     {
  7522.       tree arg = TREE_VALUE (arglist);
  7523.  
  7524.       STRIP_NOPS (arg);
  7525.       return (TREE_CODE_CLASS (TREE_CODE (arg)) == 'c'
  7526.           || (TREE_CODE (arg) == ADDR_EXPR
  7527.               && TREE_CODE (TREE_OPERAND (arg, 0)) == STRING_CST)
  7528.           ? const1_rtx : const0_rtx);
  7529.     }
  7530.  
  7531.     case BUILT_IN_FRAME_ADDRESS:
  7532.       /* The argument must be a nonnegative integer constant.
  7533.      It counts the number of frames to scan up the stack.
  7534.      The value is the address of that frame.  */
  7535.     case BUILT_IN_RETURN_ADDRESS:
  7536.       /* The argument must be a nonnegative integer constant.
  7537.      It counts the number of frames to scan up the stack.
  7538.      The value is the return address saved in that frame.  */
  7539.       if (arglist == 0)
  7540.     /* Warning about missing arg was already issued.  */
  7541.     return const0_rtx;
  7542.       else if (TREE_CODE (TREE_VALUE (arglist)) != INTEGER_CST)
  7543.     {
  7544.       error ("invalid arg to `__builtin_return_address'");
  7545.       return const0_rtx;
  7546.     }
  7547.       else if (tree_int_cst_sgn (TREE_VALUE (arglist)) < 0)
  7548.     {
  7549.       error ("invalid arg to `__builtin_return_address'");
  7550.       return const0_rtx;
  7551.     }
  7552.       else
  7553.     {
  7554.       int count = TREE_INT_CST_LOW (TREE_VALUE (arglist)); 
  7555.       rtx tem = frame_pointer_rtx;
  7556.       int i;
  7557.  
  7558.       /* Some machines need special handling before we can access arbitrary
  7559.          frames.  For example, on the sparc, we must first flush all
  7560.          register windows to the stack.  */
  7561. #ifdef SETUP_FRAME_ADDRESSES
  7562.       SETUP_FRAME_ADDRESSES ();
  7563. #endif
  7564.  
  7565.       /* On the sparc, the return address is not in the frame, it is
  7566.          in a register.  There is no way to access it off of the current
  7567.          frame pointer, but it can be accessed off the previous frame
  7568.          pointer by reading the value from the register window save
  7569.          area.  */
  7570. #ifdef RETURN_ADDR_IN_PREVIOUS_FRAME
  7571.       if (DECL_FUNCTION_CODE (fndecl) == BUILT_IN_RETURN_ADDRESS)
  7572.         count--;
  7573. #endif
  7574.  
  7575.       /* Scan back COUNT frames to the specified frame.  */
  7576.       for (i = 0; i < count; i++)
  7577.         {
  7578.           /* Assume the dynamic chain pointer is in the word that
  7579.          the frame address points to, unless otherwise specified.  */
  7580. #ifdef DYNAMIC_CHAIN_ADDRESS
  7581.           tem = DYNAMIC_CHAIN_ADDRESS (tem);
  7582. #endif
  7583.           tem = memory_address (Pmode, tem);
  7584.           tem = copy_to_reg (gen_rtx (MEM, Pmode, tem));
  7585.         }
  7586.  
  7587.       /* For __builtin_frame_address, return what we've got.  */
  7588.       if (DECL_FUNCTION_CODE (fndecl) == BUILT_IN_FRAME_ADDRESS)
  7589.         return tem;
  7590.  
  7591.       /* For __builtin_return_address,
  7592.          Get the return address from that frame.  */
  7593. #ifdef RETURN_ADDR_RTX
  7594.       return RETURN_ADDR_RTX (count, tem);
  7595. #else
  7596.       tem = memory_address (Pmode,
  7597.                 plus_constant (tem, GET_MODE_SIZE (Pmode)));
  7598.       return copy_to_reg (gen_rtx (MEM, Pmode, tem));
  7599. #endif
  7600.     }
  7601.  
  7602.     case BUILT_IN_ALLOCA:
  7603.       if (arglist == 0
  7604.       /* Arg could be non-integer if user redeclared this fcn wrong.  */
  7605.       || TREE_CODE (TREE_TYPE (TREE_VALUE (arglist))) != INTEGER_TYPE)
  7606.     break;
  7607.  
  7608.       /* Compute the argument.  */
  7609.       op0 = expand_expr (TREE_VALUE (arglist), NULL_RTX, VOIDmode, 0);
  7610.  
  7611.       /* Allocate the desired space.  */
  7612.       return allocate_dynamic_stack_space (op0, target, BITS_PER_UNIT);
  7613.  
  7614.     case BUILT_IN_FFS:
  7615.       /* If not optimizing, call the library function.  */
  7616.       if (!optimize && ! CALLED_AS_BUILT_IN (fndecl))
  7617.     break;
  7618.  
  7619.       if (arglist == 0
  7620.       /* Arg could be non-integer if user redeclared this fcn wrong.  */
  7621.       || TREE_CODE (TREE_TYPE (TREE_VALUE (arglist))) != INTEGER_TYPE)
  7622.     break;
  7623.  
  7624.       /* Compute the argument.  */
  7625.       op0 = expand_expr (TREE_VALUE (arglist), subtarget, VOIDmode, 0);
  7626.       /* Compute ffs, into TARGET if possible.
  7627.      Set TARGET to wherever the result comes back.  */
  7628.       target = expand_unop (TYPE_MODE (TREE_TYPE (TREE_VALUE (arglist))),
  7629.                 ffs_optab, op0, target, 1);
  7630.       if (target == 0)
  7631.     abort ();
  7632.       return target;
  7633.  
  7634.     case BUILT_IN_STRLEN:
  7635.       /* If not optimizing, call the library function.  */
  7636.       if (!optimize && ! CALLED_AS_BUILT_IN (fndecl))
  7637.     break;
  7638.  
  7639.       if (arglist == 0
  7640.       /* Arg could be non-pointer if user redeclared this fcn wrong.  */
  7641.       || TREE_CODE (TREE_TYPE (TREE_VALUE (arglist))) != POINTER_TYPE)
  7642.     break;
  7643.       else
  7644.     {
  7645.       tree src = TREE_VALUE (arglist);
  7646.       tree len = c_strlen (src);
  7647.  
  7648.       int align
  7649.         = get_pointer_alignment (src, BIGGEST_ALIGNMENT) / BITS_PER_UNIT;
  7650.  
  7651.       rtx result, src_rtx, char_rtx;
  7652.       enum machine_mode insn_mode = value_mode, char_mode;
  7653.       enum insn_code icode;
  7654.  
  7655.       /* If the length is known, just return it. */
  7656.       if (len != 0)
  7657.         return expand_expr (len, target, mode, 0);
  7658.  
  7659.       /* If SRC is not a pointer type, don't do this operation inline. */
  7660.       if (align == 0)
  7661.         break;
  7662.  
  7663.       /* Call a function if we can't compute strlen in the right mode. */
  7664.  
  7665.       while (insn_mode != VOIDmode)
  7666.         {
  7667.           icode = strlen_optab->handlers[(int) insn_mode].insn_code;
  7668.           if (icode != CODE_FOR_nothing)
  7669.         break;
  7670.  
  7671.           insn_mode = GET_MODE_WIDER_MODE (insn_mode);
  7672.         }
  7673.       if (insn_mode == VOIDmode)
  7674.         break;
  7675.  
  7676.       /* Make a place to write the result of the instruction.  */
  7677.       result = target;
  7678.       if (! (result != 0
  7679.          && GET_CODE (result) == REG
  7680.          && GET_MODE (result) == insn_mode
  7681.          && REGNO (result) >= FIRST_PSEUDO_REGISTER))
  7682.         result = gen_reg_rtx (insn_mode);
  7683.  
  7684.       /* Make sure the operands are acceptable to the predicates.  */
  7685.  
  7686.       if (! (*insn_operand_predicate[(int)icode][0]) (result, insn_mode))
  7687.         result = gen_reg_rtx (insn_mode);
  7688.  
  7689.       src_rtx = memory_address (BLKmode,
  7690.                     expand_expr (src, NULL_RTX, ptr_mode,
  7691.                          EXPAND_NORMAL));
  7692.       if (! (*insn_operand_predicate[(int)icode][1]) (src_rtx, Pmode))
  7693.         src_rtx = copy_to_mode_reg (Pmode, src_rtx);
  7694.  
  7695.       char_rtx = const0_rtx;
  7696.       char_mode = insn_operand_mode[(int)icode][2];
  7697.       if (! (*insn_operand_predicate[(int)icode][2]) (char_rtx, char_mode))
  7698.         char_rtx = copy_to_mode_reg (char_mode, char_rtx);
  7699.  
  7700.       emit_insn (GEN_FCN (icode) (result,
  7701.                       gen_rtx (MEM, BLKmode, src_rtx),
  7702.                       char_rtx, GEN_INT (align)));
  7703.  
  7704.       /* Return the value in the proper mode for this function.  */
  7705.       if (GET_MODE (result) == value_mode)
  7706.         return result;
  7707.       else if (target != 0)
  7708.         {
  7709.           convert_move (target, result, 0);
  7710.           return target;
  7711.         }
  7712.       else
  7713.         return convert_to_mode (value_mode, result, 0);
  7714.     }
  7715.  
  7716.     case BUILT_IN_STRCPY:
  7717.       /* If not optimizing, call the library function.  */
  7718.       if (!optimize && ! CALLED_AS_BUILT_IN (fndecl))
  7719.     break;
  7720.  
  7721.       if (arglist == 0
  7722.       /* Arg could be non-pointer if user redeclared this fcn wrong.  */
  7723.       || TREE_CODE (TREE_TYPE (TREE_VALUE (arglist))) != POINTER_TYPE
  7724.       || TREE_CHAIN (arglist) == 0
  7725.       || TREE_CODE (TREE_TYPE (TREE_VALUE (TREE_CHAIN (arglist)))) != POINTER_TYPE)
  7726.     break;
  7727.       else
  7728.     {
  7729.       tree len = c_strlen (TREE_VALUE (TREE_CHAIN (arglist)));
  7730.  
  7731.       if (len == 0)
  7732.         break;
  7733.  
  7734.       len = size_binop (PLUS_EXPR, len, integer_one_node);
  7735.  
  7736.       chainon (arglist, build_tree_list (NULL_TREE, len));
  7737.     }
  7738.  
  7739.       /* Drops in.  */
  7740.     case BUILT_IN_MEMCPY:
  7741.       /* If not optimizing, call the library function.  */
  7742.       if (!optimize && ! CALLED_AS_BUILT_IN (fndecl))
  7743.     break;
  7744.  
  7745.       if (arglist == 0
  7746.       /* Arg could be non-pointer if user redeclared this fcn wrong.  */
  7747.       || TREE_CODE (TREE_TYPE (TREE_VALUE (arglist))) != POINTER_TYPE
  7748.       || TREE_CHAIN (arglist) == 0
  7749.       || TREE_CODE (TREE_TYPE (TREE_VALUE (TREE_CHAIN (arglist)))) != POINTER_TYPE
  7750.       || TREE_CHAIN (TREE_CHAIN (arglist)) == 0
  7751.       || TREE_CODE (TREE_TYPE (TREE_VALUE (TREE_CHAIN (TREE_CHAIN (arglist))))) != INTEGER_TYPE)
  7752.     break;
  7753.       else
  7754.     {
  7755.       tree dest = TREE_VALUE (arglist);
  7756.       tree src = TREE_VALUE (TREE_CHAIN (arglist));
  7757.       tree len = TREE_VALUE (TREE_CHAIN (TREE_CHAIN (arglist)));
  7758.       tree type;
  7759.  
  7760.       int src_align
  7761.         = get_pointer_alignment (src, BIGGEST_ALIGNMENT) / BITS_PER_UNIT;
  7762.       int dest_align
  7763.         = get_pointer_alignment (dest, BIGGEST_ALIGNMENT) / BITS_PER_UNIT;
  7764.       rtx dest_rtx, dest_mem, src_mem;
  7765.  
  7766.       /* If either SRC or DEST is not a pointer type, don't do
  7767.          this operation in-line.  */
  7768.       if (src_align == 0 || dest_align == 0)
  7769.         {
  7770.           if (DECL_FUNCTION_CODE (fndecl) == BUILT_IN_STRCPY)
  7771.         TREE_CHAIN (TREE_CHAIN (arglist)) = 0;
  7772.           break;
  7773.         }
  7774.  
  7775.       dest_rtx = expand_expr (dest, NULL_RTX, ptr_mode, EXPAND_SUM);
  7776.       dest_mem = gen_rtx (MEM, BLKmode,
  7777.                   memory_address (BLKmode, dest_rtx));
  7778.       /* There could be a void* cast on top of the object.  */
  7779.       if (TREE_CODE (dest) == NOP_EXPR)
  7780.         type = TREE_TYPE (TREE_TYPE (TREE_OPERAND (dest, 0)));
  7781.       else
  7782.         type = TREE_TYPE (TREE_TYPE (dest));
  7783.       MEM_IN_STRUCT_P (dest_mem) = AGGREGATE_TYPE_P (type);
  7784.       src_mem = gen_rtx (MEM, BLKmode,
  7785.                  memory_address (BLKmode,
  7786.                          expand_expr (src, NULL_RTX,
  7787.                               ptr_mode,
  7788.                               EXPAND_SUM)));
  7789.       /* There could be a void* cast on top of the object.  */
  7790.       if (TREE_CODE (src) == NOP_EXPR)
  7791.         type = TREE_TYPE (TREE_TYPE (TREE_OPERAND (src, 0)));
  7792.       else
  7793.         type = TREE_TYPE (TREE_TYPE (src));
  7794.       MEM_IN_STRUCT_P (src_mem) = AGGREGATE_TYPE_P (type);
  7795.  
  7796.       /* Copy word part most expediently.  */
  7797.       emit_block_move (dest_mem, src_mem,
  7798.                expand_expr (len, NULL_RTX, VOIDmode, 0),
  7799.                MIN (src_align, dest_align));
  7800.       return force_operand (dest_rtx, NULL_RTX);
  7801.     }
  7802.  
  7803. /* These comparison functions need an instruction that returns an actual
  7804.    index.  An ordinary compare that just sets the condition codes
  7805.    is not enough.  */
  7806. #ifdef HAVE_cmpstrsi
  7807.     case BUILT_IN_STRCMP:
  7808.       /* If not optimizing, call the library function.  */
  7809.       if (!optimize && ! CALLED_AS_BUILT_IN (fndecl))
  7810.     break;
  7811.  
  7812.       if (arglist == 0
  7813.       /* Arg could be non-pointer if user redeclared this fcn wrong.  */
  7814.       || TREE_CODE (TREE_TYPE (TREE_VALUE (arglist))) != POINTER_TYPE
  7815.       || TREE_CHAIN (arglist) == 0
  7816.       || TREE_CODE (TREE_TYPE (TREE_VALUE (TREE_CHAIN (arglist)))) != POINTER_TYPE)
  7817.     break;
  7818.       else if (!HAVE_cmpstrsi)
  7819.     break;
  7820.       {
  7821.     tree arg1 = TREE_VALUE (arglist);
  7822.     tree arg2 = TREE_VALUE (TREE_CHAIN (arglist));
  7823.     tree offset;
  7824.     tree len, len2;
  7825.  
  7826.     len = c_strlen (arg1);
  7827.     if (len)
  7828.       len = size_binop (PLUS_EXPR, integer_one_node, len);
  7829.     len2 = c_strlen (arg2);
  7830.     if (len2)
  7831.       len2 = size_binop (PLUS_EXPR, integer_one_node, len2);
  7832.  
  7833.     /* If we don't have a constant length for the first, use the length
  7834.        of the second, if we know it.  We don't require a constant for
  7835.        this case; some cost analysis could be done if both are available
  7836.        but neither is constant.  For now, assume they're equally cheap.
  7837.  
  7838.        If both strings have constant lengths, use the smaller.  This
  7839.        could arise if optimization results in strcpy being called with
  7840.        two fixed strings, or if the code was machine-generated.  We should
  7841.        add some code to the `memcmp' handler below to deal with such
  7842.        situations, someday.  */
  7843.     if (!len || TREE_CODE (len) != INTEGER_CST)
  7844.       {
  7845.         if (len2)
  7846.           len = len2;
  7847.         else if (len == 0)
  7848.           break;
  7849.       }
  7850.     else if (len2 && TREE_CODE (len2) == INTEGER_CST)
  7851.       {
  7852.         if (tree_int_cst_lt (len2, len))
  7853.           len = len2;
  7854.       }
  7855.  
  7856.     chainon (arglist, build_tree_list (NULL_TREE, len));
  7857.       }
  7858.  
  7859.       /* Drops in.  */
  7860.     case BUILT_IN_MEMCMP:
  7861.       /* If not optimizing, call the library function.  */
  7862.       if (!optimize && ! CALLED_AS_BUILT_IN (fndecl))
  7863.     break;
  7864.  
  7865.       if (arglist == 0
  7866.       /* Arg could be non-pointer if user redeclared this fcn wrong.  */
  7867.       || TREE_CODE (TREE_TYPE (TREE_VALUE (arglist))) != POINTER_TYPE
  7868.       || TREE_CHAIN (arglist) == 0
  7869.       || TREE_CODE (TREE_TYPE (TREE_VALUE (TREE_CHAIN (arglist)))) != POINTER_TYPE
  7870.       || TREE_CHAIN (TREE_CHAIN (arglist)) == 0
  7871.       || TREE_CODE (TREE_TYPE (TREE_VALUE (TREE_CHAIN (TREE_CHAIN (arglist))))) != INTEGER_TYPE)
  7872.     break;
  7873.       else if (!HAVE_cmpstrsi)
  7874.     break;
  7875.       {
  7876.     tree arg1 = TREE_VALUE (arglist);
  7877.     tree arg2 = TREE_VALUE (TREE_CHAIN (arglist));
  7878.     tree len = TREE_VALUE (TREE_CHAIN (TREE_CHAIN (arglist)));
  7879.     rtx result;
  7880.  
  7881.     int arg1_align
  7882.       = get_pointer_alignment (arg1, BIGGEST_ALIGNMENT) / BITS_PER_UNIT;
  7883.     int arg2_align
  7884.       = get_pointer_alignment (arg2, BIGGEST_ALIGNMENT) / BITS_PER_UNIT;
  7885.     enum machine_mode insn_mode
  7886.       = insn_operand_mode[(int) CODE_FOR_cmpstrsi][0];
  7887.  
  7888.     /* If we don't have POINTER_TYPE, call the function.  */
  7889.     if (arg1_align == 0 || arg2_align == 0)
  7890.       {
  7891.         if (DECL_FUNCTION_CODE (fndecl) == BUILT_IN_STRCMP)
  7892.           TREE_CHAIN (TREE_CHAIN (arglist)) = 0;
  7893.         break;
  7894.       }
  7895.  
  7896.     /* Make a place to write the result of the instruction.  */
  7897.     result = target;
  7898.     if (! (result != 0
  7899.            && GET_CODE (result) == REG && GET_MODE (result) == insn_mode
  7900.            && REGNO (result) >= FIRST_PSEUDO_REGISTER))
  7901.       result = gen_reg_rtx (insn_mode);
  7902.  
  7903.     emit_insn (gen_cmpstrsi (result,
  7904.                  gen_rtx (MEM, BLKmode,
  7905.                       expand_expr (arg1, NULL_RTX,
  7906.                                ptr_mode,
  7907.                                EXPAND_NORMAL)),
  7908.                  gen_rtx (MEM, BLKmode,
  7909.                       expand_expr (arg2, NULL_RTX,
  7910.                                ptr_mode,
  7911.                                EXPAND_NORMAL)),
  7912.                  expand_expr (len, NULL_RTX, VOIDmode, 0),
  7913.                  GEN_INT (MIN (arg1_align, arg2_align))));
  7914.  
  7915.     /* Return the value in the proper mode for this function.  */
  7916.     mode = TYPE_MODE (TREE_TYPE (exp));
  7917.     if (GET_MODE (result) == mode)
  7918.       return result;
  7919.     else if (target != 0)
  7920.       {
  7921.         convert_move (target, result, 0);
  7922.         return target;
  7923.       }
  7924.     else
  7925.       return convert_to_mode (mode, result, 0);
  7926.       }    
  7927. #else
  7928.     case BUILT_IN_STRCMP:
  7929.     case BUILT_IN_MEMCMP:
  7930.       break;
  7931. #endif
  7932.  
  7933.     default:            /* just do library call, if unknown builtin */
  7934.       error ("built-in function `%s' not currently supported",
  7935.          IDENTIFIER_POINTER (DECL_NAME (fndecl)));
  7936.     }
  7937.  
  7938.   /* The switch statement above can drop through to cause the function
  7939.      to be called normally.  */
  7940.  
  7941.   return expand_call (exp, target, ignore);
  7942. }
  7943.  
  7944. /* Built-in functions to perform an untyped call and return.  */
  7945.  
  7946. /* For each register that may be used for calling a function, this
  7947.    gives a mode used to copy the register's value.  VOIDmode indicates
  7948.    the register is not used for calling a function.  If the machine
  7949.    has register windows, this gives only the outbound registers.
  7950.    INCOMING_REGNO gives the corresponding inbound register.  */
  7951. static enum machine_mode apply_args_mode[FIRST_PSEUDO_REGISTER];
  7952.  
  7953. /* For each register that may be used for returning values, this gives
  7954.    a mode used to copy the register's value.  VOIDmode indicates the
  7955.    register is not used for returning values.  If the machine has
  7956.    register windows, this gives only the outbound registers.
  7957.    INCOMING_REGNO gives the corresponding inbound register.  */
  7958. static enum machine_mode apply_result_mode[FIRST_PSEUDO_REGISTER];
  7959.  
  7960. /* For each register that may be used for calling a function, this
  7961.    gives the offset of that register into the block returned by
  7962.    __builtin_apply_args.  0 indicates that the register is not
  7963.    used for calling a function. */
  7964. static int apply_args_reg_offset[FIRST_PSEUDO_REGISTER];
  7965.  
  7966. /* Return the offset of register REGNO into the block returned by 
  7967.    __builtin_apply_args.  This is not declared static, since it is
  7968.    needed in objc-act.c. */
  7969.  
  7970. int 
  7971. apply_args_register_offset (regno)
  7972.      int regno;
  7973. {
  7974.   apply_args_size ();
  7975.  
  7976.   /* Arguments are always put in outgoing registers (in the argument
  7977.      block) if such make sense. */
  7978. #ifdef OUTGOING_REGNO
  7979.   regno = OUTGOING_REGNO(regno);
  7980. #endif
  7981.   return apply_args_reg_offset[regno];
  7982. }
  7983.  
  7984. /* Return the size required for the block returned by __builtin_apply_args,
  7985.    and initialize apply_args_mode.  */
  7986.  
  7987. static int
  7988. apply_args_size ()
  7989. {
  7990.   static int size = -1;
  7991.   int align, regno;
  7992.   enum machine_mode mode;
  7993.  
  7994.   /* The values computed by this function never change.  */
  7995.   if (size < 0)
  7996.     {
  7997.       /* The first value is the incoming arg-pointer.  */
  7998.       size = GET_MODE_SIZE (Pmode);
  7999.  
  8000.       /* The second value is the structure value address unless this is
  8001.      passed as an "invisible" first argument.  */
  8002.       if (struct_value_rtx)
  8003.     size += GET_MODE_SIZE (Pmode);
  8004.  
  8005.       for (regno = 0; regno < FIRST_PSEUDO_REGISTER; regno++)
  8006.     if (FUNCTION_ARG_REGNO_P (regno))
  8007.       {
  8008.         /* Search for the proper mode for copying this register's
  8009.            value.  I'm not sure this is right, but it works so far.  */
  8010.         enum machine_mode best_mode = VOIDmode;
  8011.  
  8012.         for (mode = GET_CLASS_NARROWEST_MODE (MODE_INT);
  8013.          mode != VOIDmode;
  8014.          mode = GET_MODE_WIDER_MODE (mode))
  8015.           if (HARD_REGNO_MODE_OK (regno, mode)
  8016.           && HARD_REGNO_NREGS (regno, mode) == 1)
  8017.         best_mode = mode;
  8018.  
  8019.         if (best_mode == VOIDmode)
  8020.           for (mode = GET_CLASS_NARROWEST_MODE (MODE_FLOAT);
  8021.            mode != VOIDmode;
  8022.            mode = GET_MODE_WIDER_MODE (mode))
  8023.         if (HARD_REGNO_MODE_OK (regno, mode)
  8024.             && (mov_optab->handlers[(int) mode].insn_code
  8025.             != CODE_FOR_nothing))
  8026.           best_mode = mode;
  8027.  
  8028.         mode = best_mode;
  8029.         if (mode == VOIDmode)
  8030.           abort ();
  8031.  
  8032.         align = GET_MODE_ALIGNMENT (mode) / BITS_PER_UNIT;
  8033.         if (size % align != 0)
  8034.           size = CEIL (size, align) * align;
  8035.         apply_args_reg_offset[regno] = size;
  8036.         size += GET_MODE_SIZE (mode);
  8037.         apply_args_mode[regno] = mode;
  8038.       }
  8039.     else
  8040.       {
  8041.         apply_args_mode[regno] = VOIDmode;
  8042.         apply_args_reg_offset[regno] = 0;
  8043.       }
  8044.     }
  8045.   return size;
  8046. }
  8047.  
  8048. /* Return the size required for the block returned by __builtin_apply,
  8049.    and initialize apply_result_mode.  */
  8050.  
  8051. static int
  8052. apply_result_size ()
  8053. {
  8054.   static int size = -1;
  8055.   int align, regno;
  8056.   enum machine_mode mode;
  8057.  
  8058.   /* The values computed by this function never change.  */
  8059.   if (size < 0)
  8060.     {
  8061.       size = 0;
  8062.  
  8063.       for (regno = 0; regno < FIRST_PSEUDO_REGISTER; regno++)
  8064.     if (FUNCTION_VALUE_REGNO_P (regno))
  8065.       {
  8066.         /* Search for the proper mode for copying this register's
  8067.            value.  I'm not sure this is right, but it works so far.  */
  8068.         enum machine_mode best_mode = VOIDmode;
  8069.  
  8070.         for (mode = GET_CLASS_NARROWEST_MODE (MODE_INT);
  8071.          mode != TImode;
  8072.          mode = GET_MODE_WIDER_MODE (mode))
  8073.           if (HARD_REGNO_MODE_OK (regno, mode))
  8074.         best_mode = mode;
  8075.  
  8076.         if (best_mode == VOIDmode)
  8077.           for (mode = GET_CLASS_NARROWEST_MODE (MODE_FLOAT);
  8078.            mode != VOIDmode;
  8079.            mode = GET_MODE_WIDER_MODE (mode))
  8080.         if (HARD_REGNO_MODE_OK (regno, mode)
  8081.             && (mov_optab->handlers[(int) mode].insn_code
  8082.             != CODE_FOR_nothing))
  8083.           best_mode = mode;
  8084.  
  8085.         mode = best_mode;
  8086.         if (mode == VOIDmode)
  8087.           abort ();
  8088.  
  8089.         align = GET_MODE_ALIGNMENT (mode) / BITS_PER_UNIT;
  8090.         if (size % align != 0)
  8091.           size = CEIL (size, align) * align;
  8092.         size += GET_MODE_SIZE (mode);
  8093.         apply_result_mode[regno] = mode;
  8094.       }
  8095.     else
  8096.       apply_result_mode[regno] = VOIDmode;
  8097.  
  8098.       /* Allow targets that use untyped_call and untyped_return to override
  8099.      the size so that machine-specific information can be stored here.  */
  8100. #ifdef APPLY_RESULT_SIZE
  8101.       size = APPLY_RESULT_SIZE;
  8102. #endif
  8103.     }
  8104.   return size;
  8105. }
  8106.  
  8107. #if defined (HAVE_untyped_call) || defined (HAVE_untyped_return)
  8108. /* Create a vector describing the result block RESULT.  If SAVEP is true,
  8109.    the result block is used to save the values; otherwise it is used to
  8110.    restore the values.  */
  8111.  
  8112. static rtx
  8113. result_vector (savep, result)
  8114.      int savep;
  8115.      rtx result;
  8116. {
  8117.   int regno, size, align, nelts;
  8118.   enum machine_mode mode;
  8119.   rtx reg, mem;
  8120.   rtx *savevec = (rtx *) alloca (FIRST_PSEUDO_REGISTER * sizeof (rtx));
  8121.   
  8122.   size = nelts = 0;
  8123.   for (regno = 0; regno < FIRST_PSEUDO_REGISTER; regno++)
  8124.     if ((mode = apply_result_mode[regno]) != VOIDmode)
  8125.       {
  8126.     align = GET_MODE_ALIGNMENT (mode) / BITS_PER_UNIT;
  8127.     if (size % align != 0)
  8128.       size = CEIL (size, align) * align;
  8129.     reg = gen_rtx (REG, mode, savep ? regno : INCOMING_REGNO (regno));
  8130.     mem = change_address (result, mode,
  8131.                   plus_constant (XEXP (result, 0), size));
  8132.     savevec[nelts++] = (savep
  8133.                 ? gen_rtx (SET, VOIDmode, mem, reg)
  8134.                 : gen_rtx (SET, VOIDmode, reg, mem));
  8135.     size += GET_MODE_SIZE (mode);
  8136.       }
  8137.   return gen_rtx (PARALLEL, VOIDmode, gen_rtvec_v (nelts, savevec));
  8138. }
  8139. #endif /* HAVE_untyped_call or HAVE_untyped_return */
  8140.  
  8141. /* Save the state required to perform an untyped call with the same
  8142.    arguments as were passed to the current function.  */
  8143.  
  8144. static rtx
  8145. expand_builtin_apply_args ()
  8146. {
  8147.   rtx registers;
  8148.   int size, align, regno;
  8149.   enum machine_mode mode;
  8150.  
  8151.   /* Create a block where the arg-pointer, structure value address,
  8152.      and argument registers can be saved.  */
  8153.   registers = assign_stack_local (BLKmode, apply_args_size (), -1);
  8154.  
  8155.   /* Walk past the arg-pointer and structure value address.  */
  8156.   size = GET_MODE_SIZE (Pmode);
  8157.   if (struct_value_rtx)
  8158.     size += GET_MODE_SIZE (Pmode);
  8159.  
  8160.   /* Save each register used in calling a function to the block.  */
  8161.   for (regno = 0; regno < FIRST_PSEUDO_REGISTER; regno++)
  8162.     if ((mode = apply_args_mode[regno]) != VOIDmode)
  8163.       {
  8164.     rtx tem;
  8165.  
  8166.     align = GET_MODE_ALIGNMENT (mode) / BITS_PER_UNIT;
  8167.     if (size % align != 0)
  8168.       size = CEIL (size, align) * align;
  8169.  
  8170.     tem = gen_rtx (REG, mode, INCOMING_REGNO (regno));
  8171.  
  8172. #ifdef STACK_REGS
  8173.         /* For reg-stack.c's stack register household.
  8174.        Compare with a similar piece of code in function.c.  */
  8175.  
  8176.         emit_insn (gen_rtx (USE, mode, tem));
  8177. #endif
  8178.  
  8179.     emit_move_insn (change_address (registers, mode,
  8180.                     plus_constant (XEXP (registers, 0),
  8181.                                size)),
  8182.             tem);
  8183.     size += GET_MODE_SIZE (mode);
  8184.       }
  8185.  
  8186.   /* Save the arg pointer to the block.  */
  8187.   emit_move_insn (change_address (registers, Pmode, XEXP (registers, 0)),
  8188.           copy_to_reg (virtual_incoming_args_rtx));
  8189.   size = GET_MODE_SIZE (Pmode);
  8190.  
  8191.   /* Save the structure value address unless this is passed as an
  8192.      "invisible" first argument.  */
  8193.   if (struct_value_incoming_rtx)
  8194.     {
  8195.       emit_move_insn (change_address (registers, Pmode,
  8196.                       plus_constant (XEXP (registers, 0),
  8197.                              size)),
  8198.               copy_to_reg (struct_value_incoming_rtx));
  8199.       size += GET_MODE_SIZE (Pmode);
  8200.     }
  8201.  
  8202.   /* Return the address of the block.  */
  8203.   return copy_addr_to_reg (XEXP (registers, 0));
  8204. }
  8205.  
  8206. /* Perform an untyped call and save the state required to perform an
  8207.    untyped return of whatever value was returned by the given function.  */
  8208.  
  8209. static rtx
  8210. expand_builtin_apply (function, arguments, argsize)
  8211.      rtx function, arguments, argsize;
  8212. {
  8213.   int size, align, regno;
  8214.   enum machine_mode mode;
  8215.   rtx incoming_args, result, reg, dest, call_insn;
  8216.   rtx old_stack_level = 0;
  8217.   rtx call_fusage = 0;
  8218.  
  8219.   /* Create a block where the return registers can be saved.  */
  8220.   result = assign_stack_local (BLKmode, apply_result_size (), -1);
  8221.  
  8222.   /* ??? The argsize value should be adjusted here.  */
  8223.  
  8224.   /* Fetch the arg pointer from the ARGUMENTS block.  */
  8225.   incoming_args = gen_reg_rtx (Pmode);
  8226.   emit_move_insn (incoming_args,
  8227.           gen_rtx (MEM, Pmode, arguments));
  8228. #ifndef STACK_GROWS_DOWNWARD
  8229.   incoming_args = expand_binop (Pmode, sub_optab, incoming_args, argsize,
  8230.                 incoming_args, 0, OPTAB_LIB_WIDEN);
  8231. #endif
  8232.  
  8233.   /* Perform postincrements before actually calling the function.  */
  8234.   emit_queue ();
  8235.  
  8236.   /* Push a new argument block and copy the arguments.  */
  8237.   do_pending_stack_adjust ();
  8238.   emit_stack_save (SAVE_BLOCK, &old_stack_level, NULL_RTX);
  8239.  
  8240.   /* Push a block of memory onto the stack to store the memory arguments.
  8241.      Save the address in a register, and copy the memory arguments.  ??? I
  8242.      haven't figured out how the calling convention macros effect this,
  8243.      but it's likely that the source and/or destination addresses in
  8244.      the block copy will need updating in machine specific ways.  */
  8245.   dest = copy_addr_to_reg (push_block (argsize, 0, 0));
  8246.   emit_block_move (gen_rtx (MEM, BLKmode, dest),
  8247.            gen_rtx (MEM, BLKmode, incoming_args),
  8248.            argsize,
  8249.            PARM_BOUNDARY / BITS_PER_UNIT);
  8250.  
  8251.   /* Refer to the argument block.  */
  8252.   apply_args_size ();
  8253.   arguments = gen_rtx (MEM, BLKmode, arguments);
  8254.  
  8255.   /* Walk past the arg-pointer and structure value address.  */
  8256.   size = GET_MODE_SIZE (Pmode);
  8257.   if (struct_value_rtx)
  8258.     size += GET_MODE_SIZE (Pmode);
  8259.  
  8260.   /* Restore each of the registers previously saved.  Make USE insns
  8261.      for each of these registers for use in making the call.  */
  8262.   for (regno = 0; regno < FIRST_PSEUDO_REGISTER; regno++)
  8263.     if ((mode = apply_args_mode[regno]) != VOIDmode)
  8264.       {
  8265.     align = GET_MODE_ALIGNMENT (mode) / BITS_PER_UNIT;
  8266.     if (size % align != 0)
  8267.       size = CEIL (size, align) * align;
  8268.     reg = gen_rtx (REG, mode, regno);
  8269.     emit_move_insn (reg,
  8270.             change_address (arguments, mode,
  8271.                     plus_constant (XEXP (arguments, 0),
  8272.                                size)));
  8273.  
  8274.     use_reg (&call_fusage, reg);
  8275.     size += GET_MODE_SIZE (mode);
  8276.       }
  8277.  
  8278.   /* Restore the structure value address unless this is passed as an
  8279.      "invisible" first argument.  */
  8280.   size = GET_MODE_SIZE (Pmode);
  8281.   if (struct_value_rtx)
  8282.     {
  8283.       rtx value = gen_reg_rtx (Pmode);
  8284.       emit_move_insn (value,
  8285.               change_address (arguments, Pmode,
  8286.                       plus_constant (XEXP (arguments, 0),
  8287.                              size)));
  8288.       emit_move_insn (struct_value_rtx, value);
  8289.       if (GET_CODE (struct_value_rtx) == REG)
  8290.       use_reg (&call_fusage, struct_value_rtx);
  8291.       size += GET_MODE_SIZE (Pmode);
  8292.     }
  8293.  
  8294.   /* All arguments and registers used for the call are set up by now!  */
  8295.   function = prepare_call_address (function, NULL_TREE, &call_fusage, 0);
  8296.  
  8297.   /* Ensure address is valid.  SYMBOL_REF is already valid, so no need,
  8298.      and we don't want to load it into a register as an optimization,
  8299.      because prepare_call_address already did it if it should be done.  */
  8300.   if (GET_CODE (function) != SYMBOL_REF)
  8301.     function = memory_address (FUNCTION_MODE, function);
  8302.  
  8303.   /* Generate the actual call instruction and save the return value.  */
  8304. #ifdef HAVE_untyped_call
  8305.   if (HAVE_untyped_call)
  8306.     emit_call_insn (gen_untyped_call (gen_rtx (MEM, FUNCTION_MODE, function),
  8307.                       result, result_vector (1, result)));
  8308.   else
  8309. #endif
  8310. #ifdef HAVE_call_value
  8311.   if (HAVE_call_value)
  8312.     {
  8313.       rtx valreg = 0;
  8314.  
  8315.       /* Locate the unique return register.  It is not possible to
  8316.      express a call that sets more than one return register using
  8317.      call_value; use untyped_call for that.  In fact, untyped_call
  8318.      only needs to save the return registers in the given block.  */
  8319.       for (regno = 0; regno < FIRST_PSEUDO_REGISTER; regno++)
  8320.     if ((mode = apply_result_mode[regno]) != VOIDmode)
  8321.       {
  8322.         if (valreg)
  8323.           abort (); /* HAVE_untyped_call required.  */
  8324.         valreg = gen_rtx (REG, mode, regno);
  8325.       }
  8326.  
  8327.       emit_call_insn (gen_call_value (valreg,
  8328.                       gen_rtx (MEM, FUNCTION_MODE, function),
  8329.                       const0_rtx, NULL_RTX, const0_rtx));
  8330.  
  8331.       emit_move_insn (change_address (result, GET_MODE (valreg),
  8332.                       XEXP (result, 0)),
  8333.               valreg);
  8334.     }
  8335.   else
  8336. #endif
  8337.     abort ();
  8338.  
  8339.   /* Find the CALL insn we just emitted.  */
  8340.   for (call_insn = get_last_insn ();
  8341.        call_insn && GET_CODE (call_insn) != CALL_INSN;
  8342.        call_insn = PREV_INSN (call_insn))
  8343.     ;
  8344.  
  8345.   if (! call_insn)
  8346.     abort ();
  8347.  
  8348.   /* Put the register usage information on the CALL.  If there is already
  8349.      some usage information, put ours at the end.  */
  8350.   if (CALL_INSN_FUNCTION_USAGE (call_insn))
  8351.     {
  8352.       rtx link;
  8353.  
  8354.       for (link = CALL_INSN_FUNCTION_USAGE (call_insn); XEXP (link, 1) != 0;
  8355.        link = XEXP (link, 1))
  8356.     ;
  8357.  
  8358.       XEXP (link, 1) = call_fusage;
  8359.     }
  8360.   else
  8361.     CALL_INSN_FUNCTION_USAGE (call_insn) = call_fusage;
  8362.  
  8363.   /* Restore the stack.  */
  8364.   emit_stack_restore (SAVE_BLOCK, old_stack_level, NULL_RTX);
  8365.  
  8366.   /* Return the address of the result block.  */
  8367.   return copy_addr_to_reg (XEXP (result, 0));
  8368. }
  8369.  
  8370. /* Perform an untyped return.  */
  8371.  
  8372. static void
  8373. expand_builtin_return (result)
  8374.      rtx result;
  8375. {
  8376.   int size, align, regno;
  8377.   enum machine_mode mode;
  8378.   rtx reg;
  8379.   rtx call_fusage = 0;
  8380.  
  8381.   apply_result_size ();
  8382.   result = gen_rtx (MEM, BLKmode, result);
  8383.  
  8384. #ifdef HAVE_untyped_return
  8385.   if (HAVE_untyped_return)
  8386.     {
  8387.       emit_jump_insn (gen_untyped_return (result, result_vector (0, result)));
  8388.       emit_barrier ();
  8389.       return;
  8390.     }
  8391. #endif
  8392.  
  8393.   /* Restore the return value and note that each value is used.  */
  8394.   size = 0;
  8395.   for (regno = 0; regno < FIRST_PSEUDO_REGISTER; regno++)
  8396.     if ((mode = apply_result_mode[regno]) != VOIDmode)
  8397.       {
  8398.     align = GET_MODE_ALIGNMENT (mode) / BITS_PER_UNIT;
  8399.     if (size % align != 0)
  8400.       size = CEIL (size, align) * align;
  8401.     reg = gen_rtx (REG, mode, INCOMING_REGNO (regno));
  8402.     emit_move_insn (reg,
  8403.             change_address (result, mode,
  8404.                     plus_constant (XEXP (result, 0),
  8405.                                size)));
  8406.  
  8407.     push_to_sequence (call_fusage);
  8408.     emit_insn (gen_rtx (USE, VOIDmode, reg));
  8409.     call_fusage = get_insns ();
  8410.     end_sequence ();
  8411.     size += GET_MODE_SIZE (mode);
  8412.       }
  8413.  
  8414.   /* Put the USE insns before the return.  */
  8415.   emit_insns (call_fusage);
  8416.  
  8417.   /* Return whatever values was restored by jumping directly to the end
  8418.      of the function.  */
  8419.   expand_null_return ();
  8420. }
  8421.  
  8422. /* Expand code for a post- or pre- increment or decrement
  8423.    and return the RTX for the result.
  8424.    POST is 1 for postinc/decrements and 0 for preinc/decrements.  */
  8425.  
  8426. static rtx
  8427. expand_increment (exp, post)
  8428.      register tree exp;
  8429.      int post;
  8430. {
  8431.   register rtx op0, op1;
  8432.   register rtx temp, value;
  8433.   register tree incremented = TREE_OPERAND (exp, 0);
  8434.   optab this_optab = add_optab;
  8435.   int icode;
  8436.   enum machine_mode mode = TYPE_MODE (TREE_TYPE (exp));
  8437.   int op0_is_copy = 0;
  8438.   int single_insn = 0;
  8439.   /* 1 means we can't store into OP0 directly,
  8440.      because it is a subreg narrower than a word,
  8441.      and we don't dare clobber the rest of the word.  */
  8442.   int bad_subreg = 0;
  8443.  
  8444.   if (output_bytecode)
  8445.     {
  8446.       bc_expand_expr (exp);
  8447.       return NULL_RTX;
  8448.     }
  8449.  
  8450.   /* Stabilize any component ref that might need to be
  8451.      evaluated more than once below.  */
  8452.   if (!post
  8453.       || TREE_CODE (incremented) == BIT_FIELD_REF
  8454.       || (TREE_CODE (incremented) == COMPONENT_REF
  8455.       && (TREE_CODE (TREE_OPERAND (incremented, 0)) != INDIRECT_REF
  8456.           || DECL_BIT_FIELD (TREE_OPERAND (incremented, 1)))))
  8457.     incremented = stabilize_reference (incremented);
  8458.   /* Nested *INCREMENT_EXPRs can happen in C++.  We must force innermost
  8459.      ones into save exprs so that they don't accidentally get evaluated
  8460.      more than once by the code below.  */
  8461.   if (TREE_CODE (incremented) == PREINCREMENT_EXPR
  8462.       || TREE_CODE (incremented) == PREDECREMENT_EXPR)
  8463.     incremented = save_expr (incremented);
  8464.  
  8465.   /* Compute the operands as RTX.
  8466.      Note whether OP0 is the actual lvalue or a copy of it:
  8467.      I believe it is a copy iff it is a register or subreg
  8468.      and insns were generated in computing it.   */
  8469.  
  8470.   temp = get_last_insn ();
  8471.   op0 = expand_expr (incremented, NULL_RTX, VOIDmode, 0);
  8472.  
  8473.   /* If OP0 is a SUBREG made for a promoted variable, we cannot increment
  8474.      in place but instead must do sign- or zero-extension during assignment,
  8475.      so we copy it into a new register and let the code below use it as
  8476.      a copy.
  8477.  
  8478.      Note that we can safely modify this SUBREG since it is know not to be
  8479.      shared (it was made by the expand_expr call above).  */
  8480.  
  8481.   if (GET_CODE (op0) == SUBREG && SUBREG_PROMOTED_VAR_P (op0))
  8482.     {
  8483.       if (post)
  8484.     SUBREG_REG (op0) = copy_to_reg (SUBREG_REG (op0));
  8485.       else
  8486.     bad_subreg = 1;
  8487.     }
  8488.   else if (GET_CODE (op0) == SUBREG
  8489.        && GET_MODE_BITSIZE (GET_MODE (op0)) < BITS_PER_WORD)
  8490.     {
  8491.       /* We cannot increment this SUBREG in place.  If we are
  8492.      post-incrementing, get a copy of the old value.  Otherwise,
  8493.      just mark that we cannot increment in place.  */
  8494.       if (post)
  8495.     op0 = copy_to_reg (op0);
  8496.       else
  8497.     bad_subreg = 1;
  8498.     }
  8499.  
  8500.   op0_is_copy = ((GET_CODE (op0) == SUBREG || GET_CODE (op0) == REG)
  8501.          && temp != get_last_insn ());
  8502.   op1 = expand_expr (TREE_OPERAND (exp, 1), NULL_RTX, VOIDmode, 0);
  8503.  
  8504.   /* Decide whether incrementing or decrementing.  */
  8505.   if (TREE_CODE (exp) == POSTDECREMENT_EXPR
  8506.       || TREE_CODE (exp) == PREDECREMENT_EXPR)
  8507.     this_optab = sub_optab;
  8508.  
  8509.   /* Convert decrement by a constant into a negative increment.  */
  8510.   if (this_optab == sub_optab
  8511.       && GET_CODE (op1) == CONST_INT)
  8512.     {
  8513.       op1 = GEN_INT (- INTVAL (op1));
  8514.       this_optab = add_optab;
  8515.     }
  8516.  
  8517.   /* For a preincrement, see if we can do this with a single instruction.  */
  8518.   if (!post)
  8519.     {
  8520.       icode = (int) this_optab->handlers[(int) mode].insn_code;
  8521.       if (icode != (int) CODE_FOR_nothing
  8522.       /* Make sure that OP0 is valid for operands 0 and 1
  8523.          of the insn we want to queue.  */
  8524.       && (*insn_operand_predicate[icode][0]) (op0, mode)
  8525.       && (*insn_operand_predicate[icode][1]) (op0, mode)
  8526.       && (*insn_operand_predicate[icode][2]) (op1, mode))
  8527.     single_insn = 1;
  8528.     }
  8529.  
  8530.   /* If OP0 is not the actual lvalue, but rather a copy in a register,
  8531.      then we cannot just increment OP0.  We must therefore contrive to
  8532.      increment the original value.  Then, for postincrement, we can return
  8533.      OP0 since it is a copy of the old value.  For preincrement, expand here
  8534.      unless we can do it with a single insn.
  8535.  
  8536.      Likewise if storing directly into OP0 would clobber high bits
  8537.      we need to preserve (bad_subreg).  */
  8538.   if (op0_is_copy || (!post && !single_insn) || bad_subreg)
  8539.     {
  8540.       /* This is the easiest way to increment the value wherever it is.
  8541.      Problems with multiple evaluation of INCREMENTED are prevented
  8542.      because either (1) it is a component_ref or preincrement,
  8543.      in which case it was stabilized above, or (2) it is an array_ref
  8544.      with constant index in an array in a register, which is
  8545.      safe to reevaluate.  */
  8546.       tree newexp = build (((TREE_CODE (exp) == POSTDECREMENT_EXPR
  8547.                  || TREE_CODE (exp) == PREDECREMENT_EXPR)
  8548.                 ? MINUS_EXPR : PLUS_EXPR),
  8549.                TREE_TYPE (exp),
  8550.                incremented,
  8551.                TREE_OPERAND (exp, 1));
  8552.  
  8553.       while (TREE_CODE (incremented) == NOP_EXPR
  8554.          || TREE_CODE (incremented) == CONVERT_EXPR)
  8555.     {
  8556.       newexp = convert (TREE_TYPE (incremented), newexp);
  8557.       incremented = TREE_OPERAND (incremented, 0);
  8558.     }
  8559.  
  8560.       temp = expand_assignment (incremented, newexp, ! post, 0);
  8561.       return post ? op0 : temp;
  8562.     }
  8563.  
  8564.   if (post)
  8565.     {
  8566.       /* We have a true reference to the value in OP0.
  8567.      If there is an insn to add or subtract in this mode, queue it.
  8568.      Queueing the increment insn avoids the register shuffling
  8569.      that often results if we must increment now and first save
  8570.      the old value for subsequent use.  */
  8571.  
  8572. #if 0  /* Turned off to avoid making extra insn for indexed memref.  */
  8573.       op0 = stabilize (op0);
  8574. #endif
  8575.  
  8576.       icode = (int) this_optab->handlers[(int) mode].insn_code;
  8577.       if (icode != (int) CODE_FOR_nothing
  8578.       /* Make sure that OP0 is valid for operands 0 and 1
  8579.          of the insn we want to queue.  */
  8580.       && (*insn_operand_predicate[icode][0]) (op0, mode)
  8581.       && (*insn_operand_predicate[icode][1]) (op0, mode))
  8582.     {
  8583.       if (! (*insn_operand_predicate[icode][2]) (op1, mode))
  8584.         op1 = force_reg (mode, op1);
  8585.  
  8586.       return enqueue_insn (op0, GEN_FCN (icode) (op0, op0, op1));
  8587.     }
  8588.     }
  8589.  
  8590.   /* Preincrement, or we can't increment with one simple insn.  */
  8591.   if (post)
  8592.     /* Save a copy of the value before inc or dec, to return it later.  */
  8593.     temp = value = copy_to_reg (op0);
  8594.   else
  8595.     /* Arrange to return the incremented value.  */
  8596.     /* Copy the rtx because expand_binop will protect from the queue,
  8597.        and the results of that would be invalid for us to return
  8598.        if our caller does emit_queue before using our result.  */
  8599.     temp = copy_rtx (value = op0);
  8600.  
  8601.   /* Increment however we can.  */
  8602.   op1 = expand_binop (mode, this_optab, value, op1, op0,
  8603.               TREE_UNSIGNED (TREE_TYPE (exp)), OPTAB_LIB_WIDEN);
  8604.   /* Make sure the value is stored into OP0.  */
  8605.   if (op1 != op0)
  8606.     emit_move_insn (op0, op1);
  8607.  
  8608.   return temp;
  8609. }
  8610.  
  8611. /* Expand all function calls contained within EXP, innermost ones first.
  8612.    But don't look within expressions that have sequence points.
  8613.    For each CALL_EXPR, record the rtx for its value
  8614.    in the CALL_EXPR_RTL field.  */
  8615.  
  8616. static void
  8617. preexpand_calls (exp)
  8618.      tree exp;
  8619. {
  8620.   register int nops, i;
  8621.   int type = TREE_CODE_CLASS (TREE_CODE (exp));
  8622.  
  8623.   if (! do_preexpand_calls)
  8624.     return;
  8625.  
  8626.   /* Only expressions and references can contain calls.  */
  8627.  
  8628.   if (type != 'e' && type != '<' && type != '1' && type != '2' && type != 'r')
  8629.     return;
  8630.  
  8631.   switch (TREE_CODE (exp))
  8632.     {
  8633.     case CALL_EXPR:
  8634.       /* Do nothing if already expanded.  */
  8635.       if (CALL_EXPR_RTL (exp) != 0)
  8636.     return;
  8637.  
  8638.       /* Do nothing to built-in functions.  */
  8639.       if (TREE_CODE (TREE_OPERAND (exp, 0)) != ADDR_EXPR
  8640.       || TREE_CODE (TREE_OPERAND (TREE_OPERAND (exp, 0), 0)) != FUNCTION_DECL
  8641.       || ! DECL_BUILT_IN (TREE_OPERAND (TREE_OPERAND (exp, 0), 0))
  8642.       /* Do nothing if the call returns a variable-sized object.  */
  8643.       || TREE_CODE (TYPE_SIZE (TREE_TYPE(exp))) != INTEGER_CST)
  8644.     CALL_EXPR_RTL (exp) = expand_call (exp, NULL_RTX, 0);
  8645.       return;
  8646.  
  8647.     case COMPOUND_EXPR:
  8648.     case COND_EXPR:
  8649.     case TRUTH_ANDIF_EXPR:
  8650.     case TRUTH_ORIF_EXPR:
  8651.       /* If we find one of these, then we can be sure
  8652.      the adjust will be done for it (since it makes jumps).
  8653.      Do it now, so that if this is inside an argument
  8654.      of a function, we don't get the stack adjustment
  8655.      after some other args have already been pushed.  */
  8656.       do_pending_stack_adjust ();
  8657.       return;
  8658.  
  8659.     case BLOCK:
  8660.     case RTL_EXPR:
  8661.     case WITH_CLEANUP_EXPR:
  8662.       return;
  8663.  
  8664.     case SAVE_EXPR:
  8665.       if (SAVE_EXPR_RTL (exp) != 0)
  8666.     return;
  8667.     }
  8668.  
  8669.   nops = tree_code_length[(int) TREE_CODE (exp)];
  8670.   for (i = 0; i < nops; i++)
  8671.     if (TREE_OPERAND (exp, i) != 0)
  8672.       {
  8673.     type = TREE_CODE_CLASS (TREE_CODE (TREE_OPERAND (exp, i)));
  8674.     if (type == 'e' || type == '<' || type == '1' || type == '2'
  8675.         || type == 'r')
  8676.       preexpand_calls (TREE_OPERAND (exp, i));
  8677.       }
  8678. }
  8679.  
  8680. /* At the start of a function, record that we have no previously-pushed
  8681.    arguments waiting to be popped.  */
  8682.  
  8683. void
  8684. init_pending_stack_adjust ()
  8685. {
  8686.   pending_stack_adjust = 0;
  8687. }
  8688.  
  8689. /* When exiting from function, if safe, clear out any pending stack adjust
  8690.    so the adjustment won't get done.  */
  8691.  
  8692. void
  8693. clear_pending_stack_adjust ()
  8694. {
  8695. #ifdef EXIT_IGNORE_STACK
  8696.   if (! flag_omit_frame_pointer && EXIT_IGNORE_STACK
  8697.       && ! (DECL_INLINE (current_function_decl) && ! flag_no_inline)
  8698.       && ! flag_inline_functions)
  8699.     pending_stack_adjust = 0;
  8700. #endif
  8701. }
  8702.  
  8703. /* Pop any previously-pushed arguments that have not been popped yet.  */
  8704.  
  8705. void
  8706. do_pending_stack_adjust ()
  8707. {
  8708.   if (inhibit_defer_pop == 0)
  8709.     {
  8710.       if (pending_stack_adjust != 0)
  8711.     adjust_stack (GEN_INT (pending_stack_adjust));
  8712.       pending_stack_adjust = 0;
  8713.     }
  8714. }
  8715.  
  8716. /* Defer the expansion all cleanups up to OLD_CLEANUPS.
  8717.    Returns the cleanups to be performed.  */
  8718.  
  8719. static tree
  8720. defer_cleanups_to (old_cleanups)
  8721.      tree old_cleanups;
  8722. {
  8723.   tree new_cleanups = NULL_TREE;
  8724.   tree cleanups = cleanups_this_call;
  8725.   tree last = NULL_TREE;
  8726.  
  8727.   while (cleanups_this_call != old_cleanups)
  8728.     {
  8729.       (*interim_eh_hook) (TREE_VALUE (cleanups_this_call));
  8730.       last = cleanups_this_call;
  8731.       cleanups_this_call = TREE_CHAIN (cleanups_this_call);
  8732.     }      
  8733.  
  8734.   if (last)
  8735.     {
  8736.       /* Remove the list from the chain of cleanups.  */
  8737.       TREE_CHAIN (last) = NULL_TREE;
  8738.  
  8739.       /* reverse them so that we can build them in the right order.  */
  8740.       cleanups = nreverse (cleanups);
  8741.  
  8742.       while (cleanups)
  8743.     {
  8744.       if (new_cleanups)
  8745.         new_cleanups = build (COMPOUND_EXPR, TREE_TYPE (new_cleanups),
  8746.                   TREE_VALUE (cleanups), new_cleanups);
  8747.       else
  8748.         new_cleanups = TREE_VALUE (cleanups);
  8749.  
  8750.       cleanups = TREE_CHAIN (cleanups);
  8751.     }
  8752.     }
  8753.  
  8754.   return new_cleanups;
  8755. }
  8756.  
  8757. /* Expand all cleanups up to OLD_CLEANUPS.
  8758.    Needed here, and also for language-dependent calls.  */
  8759.  
  8760. void
  8761. expand_cleanups_to (old_cleanups)
  8762.      tree old_cleanups;
  8763. {
  8764.   while (cleanups_this_call != old_cleanups)
  8765.     {
  8766.       (*interim_eh_hook) (TREE_VALUE (cleanups_this_call));
  8767.       expand_expr (TREE_VALUE (cleanups_this_call), const0_rtx, VOIDmode, 0);
  8768.       cleanups_this_call = TREE_CHAIN (cleanups_this_call);
  8769.     }
  8770. }
  8771.  
  8772. /* Expand conditional expressions.  */
  8773.  
  8774. /* Generate code to evaluate EXP and jump to LABEL if the value is zero.
  8775.    LABEL is an rtx of code CODE_LABEL, in this function and all the
  8776.    functions here.  */
  8777.  
  8778. void
  8779. jumpifnot (exp, label)
  8780.      tree exp;
  8781.      rtx label;
  8782. {
  8783.   do_jump (exp, label, NULL_RTX);
  8784. }
  8785.  
  8786. /* Generate code to evaluate EXP and jump to LABEL if the value is nonzero.  */
  8787.  
  8788. void
  8789. jumpif (exp, label)
  8790.      tree exp;
  8791.      rtx label;
  8792. {
  8793.   do_jump (exp, NULL_RTX, label);
  8794. }
  8795.  
  8796. /* Generate code to evaluate EXP and jump to IF_FALSE_LABEL if
  8797.    the result is zero, or IF_TRUE_LABEL if the result is one.
  8798.    Either of IF_FALSE_LABEL and IF_TRUE_LABEL may be zero,
  8799.    meaning fall through in that case.
  8800.  
  8801.    do_jump always does any pending stack adjust except when it does not
  8802.    actually perform a jump.  An example where there is no jump
  8803.    is when EXP is `(foo (), 0)' and IF_FALSE_LABEL is null.
  8804.  
  8805.    This function is responsible for optimizing cases such as
  8806.    &&, || and comparison operators in EXP.  */
  8807.  
  8808. void
  8809. do_jump (exp, if_false_label, if_true_label)
  8810.      tree exp;
  8811.      rtx if_false_label, if_true_label;
  8812. {
  8813.   register enum tree_code code = TREE_CODE (exp);
  8814.   /* Some cases need to create a label to jump to
  8815.      in order to properly fall through.
  8816.      These cases set DROP_THROUGH_LABEL nonzero.  */
  8817.   rtx drop_through_label = 0;
  8818.   rtx temp;
  8819.   rtx comparison = 0;
  8820.   int i;
  8821.   tree type;
  8822.   enum machine_mode mode;
  8823.  
  8824.   emit_queue ();
  8825.  
  8826.   switch (code)
  8827.     {
  8828.     case ERROR_MARK:
  8829.       break;
  8830.  
  8831.     case INTEGER_CST:
  8832.       temp = integer_zerop (exp) ? if_false_label : if_true_label;
  8833.       if (temp)
  8834.     emit_jump (temp);
  8835.       break;
  8836.  
  8837. #if 0
  8838.       /* This is not true with #pragma weak  */
  8839.     case ADDR_EXPR:
  8840.       /* The address of something can never be zero.  */
  8841.       if (if_true_label)
  8842.     emit_jump (if_true_label);
  8843.       break;
  8844. #endif
  8845.  
  8846.     case NOP_EXPR:
  8847.       if (TREE_CODE (TREE_OPERAND (exp, 0)) == COMPONENT_REF
  8848.       || TREE_CODE (TREE_OPERAND (exp, 0)) == BIT_FIELD_REF
  8849.       || TREE_CODE (TREE_OPERAND (exp, 0)) == ARRAY_REF)
  8850.     goto normal;
  8851.     case CONVERT_EXPR:
  8852.       /* If we are narrowing the operand, we have to do the compare in the
  8853.      narrower mode.  */
  8854.       if ((TYPE_PRECISION (TREE_TYPE (exp))
  8855.        < TYPE_PRECISION (TREE_TYPE (TREE_OPERAND (exp, 0)))))
  8856.     goto normal;
  8857.     case NON_LVALUE_EXPR:
  8858.     case REFERENCE_EXPR:
  8859.     case ABS_EXPR:
  8860.     case NEGATE_EXPR:
  8861.     case LROTATE_EXPR:
  8862.     case RROTATE_EXPR:
  8863.       /* These cannot change zero->non-zero or vice versa.  */
  8864.       do_jump (TREE_OPERAND (exp, 0), if_false_label, if_true_label);
  8865.       break;
  8866.  
  8867. #if 0
  8868.       /* This is never less insns than evaluating the PLUS_EXPR followed by
  8869.      a test and can be longer if the test is eliminated.  */
  8870.     case PLUS_EXPR:
  8871.       /* Reduce to minus.  */
  8872.       exp = build (MINUS_EXPR, TREE_TYPE (exp),
  8873.            TREE_OPERAND (exp, 0),
  8874.            fold (build1 (NEGATE_EXPR, TREE_TYPE (TREE_OPERAND (exp, 1)),
  8875.                  TREE_OPERAND (exp, 1))));
  8876.       /* Process as MINUS.  */
  8877. #endif
  8878.  
  8879.     case MINUS_EXPR:
  8880.       /* Non-zero iff operands of minus differ.  */
  8881.       comparison = compare (build (NE_EXPR, TREE_TYPE (exp),
  8882.                    TREE_OPERAND (exp, 0),
  8883.                    TREE_OPERAND (exp, 1)),
  8884.                 NE, NE);
  8885.       break;
  8886.  
  8887.     case BIT_AND_EXPR:
  8888.       /* If we are AND'ing with a small constant, do this comparison in the
  8889.      smallest type that fits.  If the machine doesn't have comparisons
  8890.      that small, it will be converted back to the wider comparison.
  8891.      This helps if we are testing the sign bit of a narrower object.
  8892.      combine can't do this for us because it can't know whether a
  8893.      ZERO_EXTRACT or a compare in a smaller mode exists, but we do.  */
  8894.  
  8895.       if (! SLOW_BYTE_ACCESS
  8896.       && TREE_CODE (TREE_OPERAND (exp, 1)) == INTEGER_CST
  8897.       && TYPE_PRECISION (TREE_TYPE (exp)) <= HOST_BITS_PER_WIDE_INT
  8898.       && (i = floor_log2 (TREE_INT_CST_LOW (TREE_OPERAND (exp, 1)))) >= 0
  8899.       && (mode = mode_for_size (i + 1, MODE_INT, 0)) != BLKmode
  8900.       && (type = type_for_mode (mode, 1)) != 0
  8901.       && TYPE_PRECISION (type) < TYPE_PRECISION (TREE_TYPE (exp))
  8902.       && (cmp_optab->handlers[(int) TYPE_MODE (type)].insn_code
  8903.           != CODE_FOR_nothing))
  8904.     {
  8905.       do_jump (convert (type, exp), if_false_label, if_true_label);
  8906.       break;
  8907.     }
  8908.       goto normal;
  8909.  
  8910.     case TRUTH_NOT_EXPR:
  8911.       do_jump (TREE_OPERAND (exp, 0), if_true_label, if_false_label);
  8912.       break;
  8913.  
  8914.     case TRUTH_ANDIF_EXPR:
  8915.       {
  8916.     rtx seq1, seq2;
  8917.     tree cleanups, old_cleanups;
  8918.  
  8919.     if (if_false_label == 0)
  8920.       if_false_label = drop_through_label = gen_label_rtx ();
  8921.     start_sequence ();
  8922.     do_jump (TREE_OPERAND (exp, 0), if_false_label, NULL_RTX);
  8923.     seq1 = get_insns ();
  8924.     end_sequence ();
  8925.  
  8926.     old_cleanups = cleanups_this_call;
  8927.     start_sequence ();
  8928.     do_jump (TREE_OPERAND (exp, 1), if_false_label, if_true_label);
  8929.     seq2 = get_insns ();
  8930.     end_sequence ();
  8931.  
  8932.     cleanups = defer_cleanups_to (old_cleanups);
  8933.     if (cleanups)
  8934.       {
  8935.         rtx flag = gen_reg_rtx (word_mode);
  8936.         tree new_cleanups;
  8937.         tree cond;
  8938.  
  8939.         /* Flag cleanups as not needed. */
  8940.         emit_move_insn (flag, const0_rtx);
  8941.         emit_insns (seq1);
  8942.  
  8943.         /* Flag cleanups as needed. */
  8944.         emit_move_insn (flag, const1_rtx);
  8945.         emit_insns (seq2);
  8946.  
  8947.         /* convert flag, which is an rtx, into a tree. */
  8948.         cond = make_node (RTL_EXPR);
  8949.         TREE_TYPE (cond) = integer_type_node;
  8950.         RTL_EXPR_RTL (cond) = flag;
  8951.         RTL_EXPR_SEQUENCE (cond) = NULL_RTX;
  8952.  
  8953.         new_cleanups = build (COND_EXPR, void_type_node,
  8954.                   truthvalue_conversion (cond),
  8955.                   cleanups, integer_zero_node);
  8956.         new_cleanups = fold (new_cleanups);
  8957.  
  8958.         /* Now add in the conditionalized cleanups. */
  8959.         cleanups_this_call
  8960.           = tree_cons (NULL_TREE, new_cleanups, cleanups_this_call);
  8961.         (*interim_eh_hook) (NULL_TREE);
  8962.       }
  8963.     else
  8964.       {
  8965.         emit_insns (seq1);
  8966.         emit_insns (seq2);
  8967.       }
  8968.       }
  8969.       break;
  8970.  
  8971.     case TRUTH_ORIF_EXPR:
  8972.       {
  8973.     rtx seq1, seq2;
  8974.     tree cleanups, old_cleanups;
  8975.  
  8976.     if (if_true_label == 0)
  8977.       if_true_label = drop_through_label = gen_label_rtx ();
  8978.     start_sequence ();
  8979.     do_jump (TREE_OPERAND (exp, 0), NULL_RTX, if_true_label);
  8980.     seq1 = get_insns ();
  8981.     end_sequence ();
  8982.  
  8983.     old_cleanups = cleanups_this_call;
  8984.     start_sequence ();
  8985.     do_jump (TREE_OPERAND (exp, 1), if_false_label, if_true_label);
  8986.     seq2 = get_insns ();
  8987.     end_sequence ();
  8988.  
  8989.     cleanups = defer_cleanups_to (old_cleanups);
  8990.     if (cleanups)
  8991.       {
  8992.         rtx flag = gen_reg_rtx (word_mode);
  8993.         tree new_cleanups;
  8994.         tree cond;
  8995.  
  8996.         /* Flag cleanups as not needed. */
  8997.         emit_move_insn (flag, const0_rtx);
  8998.         emit_insns (seq1);
  8999.  
  9000.         /* Flag cleanups as needed. */
  9001.         emit_move_insn (flag, const1_rtx);
  9002.         emit_insns (seq2);
  9003.  
  9004.         /* convert flag, which is an rtx, into a tree. */
  9005.         cond = make_node (RTL_EXPR);
  9006.         TREE_TYPE (cond) = integer_type_node;
  9007.         RTL_EXPR_RTL (cond) = flag;
  9008.         RTL_EXPR_SEQUENCE (cond) = NULL_RTX;
  9009.  
  9010.         new_cleanups = build (COND_EXPR, void_type_node,
  9011.                   truthvalue_conversion (cond),
  9012.                   cleanups, integer_zero_node);
  9013.         new_cleanups = fold (new_cleanups);
  9014.  
  9015.         /* Now add in the conditionalized cleanups. */
  9016.         cleanups_this_call
  9017.           = tree_cons (NULL_TREE, new_cleanups, cleanups_this_call);
  9018.         (*interim_eh_hook) (NULL_TREE);
  9019.       }
  9020.     else
  9021.       {
  9022.         emit_insns (seq1);
  9023.         emit_insns (seq2);
  9024.       }
  9025.       }
  9026.       break;
  9027.  
  9028.     case COMPOUND_EXPR:
  9029.       push_temp_slots ();
  9030.       expand_expr (TREE_OPERAND (exp, 0), const0_rtx, VOIDmode, 0);
  9031.       free_temp_slots ();
  9032.       pop_temp_slots ();
  9033.       emit_queue ();
  9034.       do_pending_stack_adjust ();
  9035.       do_jump (TREE_OPERAND (exp, 1), if_false_label, if_true_label);
  9036.       break;
  9037.  
  9038.     case COMPONENT_REF:
  9039.     case BIT_FIELD_REF:
  9040.     case ARRAY_REF:
  9041.       {
  9042.     int bitsize, bitpos, unsignedp;
  9043.     enum machine_mode mode;
  9044.     tree type;
  9045.     tree offset;
  9046.     int volatilep = 0;
  9047.  
  9048.     /* Get description of this reference.  We don't actually care
  9049.        about the underlying object here.  */
  9050.     get_inner_reference (exp, &bitsize, &bitpos, &offset,
  9051.                  &mode, &unsignedp, &volatilep);
  9052.  
  9053.     type = type_for_size (bitsize, unsignedp);
  9054.     if (! SLOW_BYTE_ACCESS
  9055.         && type != 0 && bitsize >= 0
  9056.         && TYPE_PRECISION (type) < TYPE_PRECISION (TREE_TYPE (exp))
  9057.         && (cmp_optab->handlers[(int) TYPE_MODE (type)].insn_code
  9058.         != CODE_FOR_nothing))
  9059.       {
  9060.         do_jump (convert (type, exp), if_false_label, if_true_label);
  9061.         break;
  9062.       }
  9063.     goto normal;
  9064.       }
  9065.  
  9066.     case COND_EXPR:
  9067.       /* Do (a ? 1 : 0) and (a ? 0 : 1) as special cases.  */
  9068.       if (integer_onep (TREE_OPERAND (exp, 1))
  9069.       && integer_zerop (TREE_OPERAND (exp, 2)))
  9070.     do_jump (TREE_OPERAND (exp, 0), if_false_label, if_true_label);
  9071.  
  9072.       else if (integer_zerop (TREE_OPERAND (exp, 1))
  9073.            && integer_onep (TREE_OPERAND (exp, 2)))
  9074.     do_jump (TREE_OPERAND (exp, 0), if_true_label, if_false_label);
  9075.  
  9076.       else
  9077.     {
  9078.       register rtx label1 = gen_label_rtx ();
  9079.       drop_through_label = gen_label_rtx ();
  9080.       do_jump (TREE_OPERAND (exp, 0), label1, NULL_RTX);
  9081.       /* Now the THEN-expression.  */
  9082.       do_jump (TREE_OPERAND (exp, 1),
  9083.            if_false_label ? if_false_label : drop_through_label,
  9084.            if_true_label ? if_true_label : drop_through_label);
  9085.       /* In case the do_jump just above never jumps.  */
  9086.       do_pending_stack_adjust ();
  9087.       emit_label (label1);
  9088.       /* Now the ELSE-expression.  */
  9089.       do_jump (TREE_OPERAND (exp, 2),
  9090.            if_false_label ? if_false_label : drop_through_label,
  9091.            if_true_label ? if_true_label : drop_through_label);
  9092.     }
  9093.       break;
  9094.  
  9095.     case EQ_EXPR:
  9096.       {
  9097.     tree inner_type = TREE_TYPE (TREE_OPERAND (exp, 0));
  9098.  
  9099.     if (integer_zerop (TREE_OPERAND (exp, 1)))
  9100.       do_jump (TREE_OPERAND (exp, 0), if_true_label, if_false_label);
  9101.     else if (GET_MODE_CLASS (TYPE_MODE (inner_type)) == MODE_COMPLEX_FLOAT
  9102.          || GET_MODE_CLASS (TYPE_MODE (inner_type)) == MODE_COMPLEX_INT)
  9103.       do_jump
  9104.         (fold
  9105.          (build (TRUTH_ANDIF_EXPR, TREE_TYPE (exp),
  9106.              fold (build (EQ_EXPR, TREE_TYPE (exp),
  9107.                   fold (build1 (REALPART_EXPR,
  9108.                         TREE_TYPE (inner_type),
  9109.                         TREE_OPERAND (exp, 0))),
  9110.                   fold (build1 (REALPART_EXPR,
  9111.                         TREE_TYPE (inner_type),
  9112.                         TREE_OPERAND (exp, 1))))),
  9113.              fold (build (EQ_EXPR, TREE_TYPE (exp),
  9114.                   fold (build1 (IMAGPART_EXPR,
  9115.                         TREE_TYPE (inner_type),
  9116.                         TREE_OPERAND (exp, 0))),
  9117.                   fold (build1 (IMAGPART_EXPR,
  9118.                         TREE_TYPE (inner_type),
  9119.                         TREE_OPERAND (exp, 1))))))),
  9120.          if_false_label, if_true_label);
  9121.     else if (GET_MODE_CLASS (TYPE_MODE (inner_type)) == MODE_INT
  9122.          && !can_compare_p (TYPE_MODE (inner_type)))
  9123.       do_jump_by_parts_equality (exp, if_false_label, if_true_label);
  9124.     else
  9125.       comparison = compare (exp, EQ, EQ);
  9126.     break;
  9127.       }
  9128.  
  9129.     case NE_EXPR:
  9130.       {
  9131.     tree inner_type = TREE_TYPE (TREE_OPERAND (exp, 0));
  9132.  
  9133.     if (integer_zerop (TREE_OPERAND (exp, 1)))
  9134.       do_jump (TREE_OPERAND (exp, 0), if_false_label, if_true_label);
  9135.     else if (GET_MODE_CLASS (TYPE_MODE (inner_type)) == MODE_COMPLEX_FLOAT
  9136.          || GET_MODE_CLASS (TYPE_MODE (inner_type)) == MODE_COMPLEX_INT)
  9137.       do_jump
  9138.         (fold
  9139.          (build (TRUTH_ORIF_EXPR, TREE_TYPE (exp),
  9140.              fold (build (NE_EXPR, TREE_TYPE (exp),
  9141.                   fold (build1 (REALPART_EXPR,
  9142.                         TREE_TYPE (inner_type),
  9143.                         TREE_OPERAND (exp, 0))),
  9144.                   fold (build1 (REALPART_EXPR,
  9145.                         TREE_TYPE (inner_type),
  9146.                         TREE_OPERAND (exp, 1))))),
  9147.              fold (build (NE_EXPR, TREE_TYPE (exp),
  9148.                   fold (build1 (IMAGPART_EXPR,
  9149.                         TREE_TYPE (inner_type),
  9150.                         TREE_OPERAND (exp, 0))),
  9151.                   fold (build1 (IMAGPART_EXPR,
  9152.                         TREE_TYPE (inner_type),
  9153.                         TREE_OPERAND (exp, 1))))))),
  9154.          if_false_label, if_true_label);
  9155.     else if (GET_MODE_CLASS (TYPE_MODE (inner_type)) == MODE_INT
  9156.          && !can_compare_p (TYPE_MODE (inner_type)))
  9157.       do_jump_by_parts_equality (exp, if_true_label, if_false_label);
  9158.     else
  9159.       comparison = compare (exp, NE, NE);
  9160.     break;
  9161.       }
  9162.  
  9163.     case LT_EXPR:
  9164.       if ((GET_MODE_CLASS (TYPE_MODE (TREE_TYPE (TREE_OPERAND (exp, 0))))
  9165.        == MODE_INT)
  9166.       && !can_compare_p (TYPE_MODE (TREE_TYPE (TREE_OPERAND (exp, 0)))))
  9167.     do_jump_by_parts_greater (exp, 1, if_false_label, if_true_label);
  9168.       else
  9169.     comparison = compare (exp, LT, LTU);
  9170.       break;
  9171.  
  9172.     case LE_EXPR:
  9173.       if ((GET_MODE_CLASS (TYPE_MODE (TREE_TYPE (TREE_OPERAND (exp, 0))))
  9174.        == MODE_INT)
  9175.       && !can_compare_p (TYPE_MODE (TREE_TYPE (TREE_OPERAND (exp, 0)))))
  9176.     do_jump_by_parts_greater (exp, 0, if_true_label, if_false_label);
  9177.       else
  9178.     comparison = compare (exp, LE, LEU);
  9179.       break;
  9180.  
  9181.     case GT_EXPR:
  9182.       if ((GET_MODE_CLASS (TYPE_MODE (TREE_TYPE (TREE_OPERAND (exp, 0))))
  9183.        == MODE_INT)
  9184.       && !can_compare_p (TYPE_MODE (TREE_TYPE (TREE_OPERAND (exp, 0)))))
  9185.     do_jump_by_parts_greater (exp, 0, if_false_label, if_true_label);
  9186.       else
  9187.     comparison = compare (exp, GT, GTU);
  9188.       break;
  9189.  
  9190.     case GE_EXPR:
  9191.       if ((GET_MODE_CLASS (TYPE_MODE (TREE_TYPE (TREE_OPERAND (exp, 0))))
  9192.        == MODE_INT)
  9193.       && !can_compare_p (TYPE_MODE (TREE_TYPE (TREE_OPERAND (exp, 0)))))
  9194.     do_jump_by_parts_greater (exp, 1, if_true_label, if_false_label);
  9195.       else
  9196.     comparison = compare (exp, GE, GEU);
  9197.       break;
  9198.  
  9199.     default:
  9200.     normal:
  9201.       temp = expand_expr (exp, NULL_RTX, VOIDmode, 0);
  9202. #if 0
  9203.       /* This is not needed any more and causes poor code since it causes
  9204.      comparisons and tests from non-SI objects to have different code
  9205.      sequences.  */
  9206.       /* Copy to register to avoid generating bad insns by cse
  9207.      from (set (mem ...) (arithop))  (set (cc0) (mem ...)).  */
  9208.       if (!cse_not_expected && GET_CODE (temp) == MEM)
  9209.     temp = copy_to_reg (temp);
  9210. #endif
  9211.       do_pending_stack_adjust ();
  9212.       if (GET_CODE (temp) == CONST_INT)
  9213.     comparison = (temp == const0_rtx ? const0_rtx : const_true_rtx);
  9214.       else if (GET_CODE (temp) == LABEL_REF)
  9215.     comparison = const_true_rtx;
  9216.       else if (GET_MODE_CLASS (GET_MODE (temp)) == MODE_INT
  9217.            && !can_compare_p (GET_MODE (temp)))
  9218.     /* Note swapping the labels gives us not-equal.  */
  9219.     do_jump_by_parts_equality_rtx (temp, if_true_label, if_false_label);
  9220.       else if (GET_MODE (temp) != VOIDmode)
  9221.     comparison = compare_from_rtx (temp, CONST0_RTX (GET_MODE (temp)),
  9222.                        NE, TREE_UNSIGNED (TREE_TYPE (exp)),
  9223.                        GET_MODE (temp), NULL_RTX, 0);
  9224.       else
  9225.     abort ();
  9226.     }
  9227.  
  9228.   /* Do any postincrements in the expression that was tested.  */
  9229.   emit_queue ();
  9230.  
  9231.   /* If COMPARISON is nonzero here, it is an rtx that can be substituted
  9232.      straight into a conditional jump instruction as the jump condition.
  9233.      Otherwise, all the work has been done already.  */
  9234.  
  9235.   if (comparison == const_true_rtx)
  9236.     {
  9237.       if (if_true_label)
  9238.     emit_jump (if_true_label);
  9239.     }
  9240.   else if (comparison == const0_rtx)
  9241.     {
  9242.       if (if_false_label)
  9243.     emit_jump (if_false_label);
  9244.     }
  9245.   else if (comparison)
  9246.     do_jump_for_compare (comparison, if_false_label, if_true_label);
  9247.  
  9248.   if (drop_through_label)
  9249.     {
  9250.       /* If do_jump produces code that might be jumped around,
  9251.      do any stack adjusts from that code, before the place
  9252.      where control merges in.  */
  9253.       do_pending_stack_adjust ();
  9254.       emit_label (drop_through_label);
  9255.     }
  9256. }
  9257.  
  9258. /* Given a comparison expression EXP for values too wide to be compared
  9259.    with one insn, test the comparison and jump to the appropriate label.
  9260.    The code of EXP is ignored; we always test GT if SWAP is 0,
  9261.    and LT if SWAP is 1.  */
  9262.  
  9263. static void
  9264. do_jump_by_parts_greater (exp, swap, if_false_label, if_true_label)
  9265.      tree exp;
  9266.      int swap;
  9267.      rtx if_false_label, if_true_label;
  9268. {
  9269.   rtx op0 = expand_expr (TREE_OPERAND (exp, swap), NULL_RTX, VOIDmode, 0);
  9270.   rtx op1 = expand_expr (TREE_OPERAND (exp, !swap), NULL_RTX, VOIDmode, 0);
  9271.   enum machine_mode mode = TYPE_MODE (TREE_TYPE (TREE_OPERAND (exp, 0)));
  9272.   int nwords = (GET_MODE_SIZE (mode) / UNITS_PER_WORD);
  9273.   rtx drop_through_label = 0;
  9274.   int unsignedp = TREE_UNSIGNED (TREE_TYPE (TREE_OPERAND (exp, 0)));
  9275.   int i;
  9276.  
  9277.   if (! if_true_label || ! if_false_label)
  9278.     drop_through_label = gen_label_rtx ();
  9279.   if (! if_true_label)
  9280.     if_true_label = drop_through_label;
  9281.   if (! if_false_label)
  9282.     if_false_label = drop_through_label;
  9283.  
  9284.   /* Compare a word at a time, high order first.  */
  9285.   for (i = 0; i < nwords; i++)
  9286.     {
  9287.       rtx comp;
  9288.       rtx op0_word, op1_word;
  9289.  
  9290.       if (WORDS_BIG_ENDIAN)
  9291.     {
  9292.       op0_word = operand_subword_force (op0, i, mode);
  9293.       op1_word = operand_subword_force (op1, i, mode);
  9294.     }
  9295.       else
  9296.     {
  9297.       op0_word = operand_subword_force (op0, nwords - 1 - i, mode);
  9298.       op1_word = operand_subword_force (op1, nwords - 1 - i, mode);
  9299.     }
  9300.  
  9301.       /* All but high-order word must be compared as unsigned.  */
  9302.       comp = compare_from_rtx (op0_word, op1_word,
  9303.                    (unsignedp || i > 0) ? GTU : GT,
  9304.                    unsignedp, word_mode, NULL_RTX, 0);
  9305.       if (comp == const_true_rtx)
  9306.     emit_jump (if_true_label);
  9307.       else if (comp != const0_rtx)
  9308.     do_jump_for_compare (comp, NULL_RTX, if_true_label);
  9309.  
  9310.       /* Consider lower words only if these are equal.  */
  9311.       comp = compare_from_rtx (op0_word, op1_word, NE, unsignedp, word_mode,
  9312.                    NULL_RTX, 0);
  9313.       if (comp == const_true_rtx)
  9314.     emit_jump (if_false_label);
  9315.       else if (comp != const0_rtx)
  9316.     do_jump_for_compare (comp, NULL_RTX, if_false_label);
  9317.     }
  9318.  
  9319.   if (if_false_label)
  9320.     emit_jump (if_false_label);
  9321.   if (drop_through_label)
  9322.     emit_label (drop_through_label);
  9323. }
  9324.  
  9325. /* Compare OP0 with OP1, word at a time, in mode MODE.
  9326.    UNSIGNEDP says to do unsigned comparison.
  9327.    Jump to IF_TRUE_LABEL if OP0 is greater, IF_FALSE_LABEL otherwise.  */
  9328.  
  9329. void
  9330. do_jump_by_parts_greater_rtx (mode, unsignedp, op0, op1, if_false_label, if_true_label)
  9331.      enum machine_mode mode;
  9332.      int unsignedp;
  9333.      rtx op0, op1;
  9334.      rtx if_false_label, if_true_label;
  9335. {
  9336.   int nwords = (GET_MODE_SIZE (mode) / UNITS_PER_WORD);
  9337.   rtx drop_through_label = 0;
  9338.   int i;
  9339.  
  9340.   if (! if_true_label || ! if_false_label)
  9341.     drop_through_label = gen_label_rtx ();
  9342.   if (! if_true_label)
  9343.     if_true_label = drop_through_label;
  9344.   if (! if_false_label)
  9345.     if_false_label = drop_through_label;
  9346.  
  9347.   /* Compare a word at a time, high order first.  */
  9348.   for (i = 0; i < nwords; i++)
  9349.     {
  9350.       rtx comp;
  9351.       rtx op0_word, op1_word;
  9352.  
  9353.       if (WORDS_BIG_ENDIAN)
  9354.     {
  9355.       op0_word = operand_subword_force (op0, i, mode);
  9356.       op1_word = operand_subword_force (op1, i, mode);
  9357.     }
  9358.       else
  9359.     {
  9360.       op0_word = operand_subword_force (op0, nwords - 1 - i, mode);
  9361.       op1_word = operand_subword_force (op1, nwords - 1 - i, mode);
  9362.     }
  9363.  
  9364.       /* All but high-order word must be compared as unsigned.  */
  9365.       comp = compare_from_rtx (op0_word, op1_word,
  9366.                    (unsignedp || i > 0) ? GTU : GT,
  9367.                    unsignedp, word_mode, NULL_RTX, 0);
  9368.       if (comp == const_true_rtx)
  9369.     emit_jump (if_true_label);
  9370.       else if (comp != const0_rtx)
  9371.     do_jump_for_compare (comp, NULL_RTX, if_true_label);
  9372.  
  9373.       /* Consider lower words only if these are equal.  */
  9374.       comp = compare_from_rtx (op0_word, op1_word, NE, unsignedp, word_mode,
  9375.                    NULL_RTX, 0);
  9376.       if (comp == const_true_rtx)
  9377.     emit_jump (if_false_label);
  9378.       else if (comp != const0_rtx)
  9379.     do_jump_for_compare (comp, NULL_RTX, if_false_label);
  9380.     }
  9381.  
  9382.   if (if_false_label)
  9383.     emit_jump (if_false_label);
  9384.   if (drop_through_label)
  9385.     emit_label (drop_through_label);
  9386. }
  9387.  
  9388. /* Given an EQ_EXPR expression EXP for values too wide to be compared
  9389.    with one insn, test the comparison and jump to the appropriate label.  */
  9390.  
  9391. static void
  9392. do_jump_by_parts_equality (exp, if_false_label, if_true_label)
  9393.      tree exp;
  9394.      rtx if_false_label, if_true_label;
  9395. {
  9396.   rtx op0 = expand_expr (TREE_OPERAND (exp, 0), NULL_RTX, VOIDmode, 0);
  9397.   rtx op1 = expand_expr (TREE_OPERAND (exp, 1), NULL_RTX, VOIDmode, 0);
  9398.   enum machine_mode mode = TYPE_MODE (TREE_TYPE (TREE_OPERAND (exp, 0)));
  9399.   int nwords = (GET_MODE_SIZE (mode) / UNITS_PER_WORD);
  9400.   int i;
  9401.   rtx drop_through_label = 0;
  9402.  
  9403.   if (! if_false_label)
  9404.     drop_through_label = if_false_label = gen_label_rtx ();
  9405.  
  9406.   for (i = 0; i < nwords; i++)
  9407.     {
  9408.       rtx comp = compare_from_rtx (operand_subword_force (op0, i, mode),
  9409.                    operand_subword_force (op1, i, mode),
  9410.                    EQ, TREE_UNSIGNED (TREE_TYPE (exp)),
  9411.                    word_mode, NULL_RTX, 0);
  9412.       if (comp == const_true_rtx)
  9413.     emit_jump (if_false_label);
  9414.       else if (comp != const0_rtx)
  9415.     do_jump_for_compare (comp, if_false_label, NULL_RTX);
  9416.     }
  9417.  
  9418.   if (if_true_label)
  9419.     emit_jump (if_true_label);
  9420.   if (drop_through_label)
  9421.     emit_label (drop_through_label);
  9422. }
  9423.  
  9424. /* Jump according to whether OP0 is 0.
  9425.    We assume that OP0 has an integer mode that is too wide
  9426.    for the available compare insns.  */
  9427.  
  9428. static void
  9429. do_jump_by_parts_equality_rtx (op0, if_false_label, if_true_label)
  9430.      rtx op0;
  9431.      rtx if_false_label, if_true_label;
  9432. {
  9433.   int nwords = GET_MODE_SIZE (GET_MODE (op0)) / UNITS_PER_WORD;
  9434.   int i;
  9435.   rtx drop_through_label = 0;
  9436.  
  9437.   if (! if_false_label)
  9438.     drop_through_label = if_false_label = gen_label_rtx ();
  9439.  
  9440.   for (i = 0; i < nwords; i++)
  9441.     {
  9442.       rtx comp = compare_from_rtx (operand_subword_force (op0, i,
  9443.                               GET_MODE (op0)),
  9444.                    const0_rtx, EQ, 1, word_mode, NULL_RTX, 0);
  9445.       if (comp == const_true_rtx)
  9446.     emit_jump (if_false_label);
  9447.       else if (comp != const0_rtx)
  9448.     do_jump_for_compare (comp, if_false_label, NULL_RTX);
  9449.     }
  9450.  
  9451.   if (if_true_label)
  9452.     emit_jump (if_true_label);
  9453.   if (drop_through_label)
  9454.     emit_label (drop_through_label);
  9455. }
  9456.  
  9457. /* Given a comparison expression in rtl form, output conditional branches to
  9458.    IF_TRUE_LABEL, IF_FALSE_LABEL, or both.  */
  9459.  
  9460. static void
  9461. do_jump_for_compare (comparison, if_false_label, if_true_label)
  9462.      rtx comparison, if_false_label, if_true_label;
  9463. {
  9464.   if (if_true_label)
  9465.     {
  9466.       if (bcc_gen_fctn[(int) GET_CODE (comparison)] != 0)
  9467.     emit_jump_insn ((*bcc_gen_fctn[(int) GET_CODE (comparison)]) (if_true_label));
  9468.       else
  9469.     abort ();
  9470.  
  9471.       if (if_false_label)
  9472.     emit_jump (if_false_label);
  9473.     }
  9474.   else if (if_false_label)
  9475.     {
  9476.       rtx insn;
  9477.       rtx prev = get_last_insn ();
  9478.       rtx branch = 0;
  9479.  
  9480.       /* Output the branch with the opposite condition.  Then try to invert
  9481.      what is generated.  If more than one insn is a branch, or if the
  9482.      branch is not the last insn written, abort. If we can't invert
  9483.      the branch, emit make a true label, redirect this jump to that,
  9484.      emit a jump to the false label and define the true label.  */
  9485.  
  9486.       if (bcc_gen_fctn[(int) GET_CODE (comparison)] != 0)
  9487.     emit_jump_insn ((*bcc_gen_fctn[(int) GET_CODE (comparison)])(if_false_label));
  9488.       else
  9489.     abort ();
  9490.  
  9491.       /* Here we get the first insn that was just emitted.  It used to be  the
  9492.      case that, on some machines, emitting the branch would discard
  9493.      the previous compare insn and emit a replacement.  This isn't
  9494.      done anymore, but abort if we see that PREV is deleted.  */
  9495.  
  9496.       if (prev == 0)
  9497.     insn = get_insns ();
  9498.       else if (INSN_DELETED_P (prev))
  9499.     abort ();
  9500.       else
  9501.     insn = NEXT_INSN (prev);
  9502.  
  9503.       for (; insn; insn = NEXT_INSN (insn))
  9504.     if (GET_CODE (insn) == JUMP_INSN)
  9505.       {
  9506.         if (branch)
  9507.           abort ();
  9508.         branch = insn;
  9509.       }
  9510.  
  9511.       if (branch != get_last_insn ())
  9512.     abort ();
  9513.  
  9514.       JUMP_LABEL (branch) = if_false_label;
  9515.       if (! invert_jump (branch, if_false_label))
  9516.     {
  9517.       if_true_label = gen_label_rtx ();
  9518.       redirect_jump (branch, if_true_label);
  9519.       emit_jump (if_false_label);
  9520.       emit_label (if_true_label);
  9521.     }
  9522.     }
  9523. }
  9524.  
  9525. /* Generate code for a comparison expression EXP
  9526.    (including code to compute the values to be compared)
  9527.    and set (CC0) according to the result.
  9528.    SIGNED_CODE should be the rtx operation for this comparison for
  9529.    signed data; UNSIGNED_CODE, likewise for use if data is unsigned.
  9530.  
  9531.    We force a stack adjustment unless there are currently
  9532.    things pushed on the stack that aren't yet used.  */
  9533.  
  9534. static rtx
  9535. compare (exp, signed_code, unsigned_code)
  9536.      register tree exp;
  9537.      enum rtx_code signed_code, unsigned_code;
  9538. {
  9539.   register rtx op0
  9540.     = expand_expr (TREE_OPERAND (exp, 0), NULL_RTX, VOIDmode, 0);
  9541.   register rtx op1
  9542.     = expand_expr (TREE_OPERAND (exp, 1), NULL_RTX, VOIDmode, 0);
  9543.   register tree type = TREE_TYPE (TREE_OPERAND (exp, 0));
  9544.   register enum machine_mode mode = TYPE_MODE (type);
  9545.   int unsignedp = TREE_UNSIGNED (type);
  9546.   enum rtx_code code = unsignedp ? unsigned_code : signed_code;
  9547.  
  9548.   return compare_from_rtx (op0, op1, code, unsignedp, mode,
  9549.                ((mode == BLKmode)
  9550.                 ? expr_size (TREE_OPERAND (exp, 0)) : NULL_RTX),
  9551.                TYPE_ALIGN (TREE_TYPE (exp)) / BITS_PER_UNIT);
  9552. }
  9553.  
  9554. /* Like compare but expects the values to compare as two rtx's.
  9555.    The decision as to signed or unsigned comparison must be made by the caller.
  9556.  
  9557.    If MODE is BLKmode, SIZE is an RTX giving the size of the objects being
  9558.    compared.
  9559.  
  9560.    If ALIGN is non-zero, it is the alignment of this type; if zero, the
  9561.    size of MODE should be used.  */
  9562.  
  9563. rtx
  9564. compare_from_rtx (op0, op1, code, unsignedp, mode, size, align)
  9565.      register rtx op0, op1;
  9566.      enum rtx_code code;
  9567.      int unsignedp;
  9568.      enum machine_mode mode;
  9569.      rtx size;
  9570.      int align;
  9571. {
  9572.   rtx tem;
  9573.  
  9574.   /* If one operand is constant, make it the second one.  Only do this
  9575.      if the other operand is not constant as well.  */
  9576.  
  9577.   if ((CONSTANT_P (op0) && ! CONSTANT_P (op1))
  9578.       || (GET_CODE (op0) == CONST_INT && GET_CODE (op1) != CONST_INT))
  9579.     {
  9580.       tem = op0;
  9581.       op0 = op1;
  9582.       op1 = tem;
  9583.       code = swap_condition (code);
  9584.     }
  9585.  
  9586.   if (flag_force_mem)
  9587.     {
  9588.       op0 = force_not_mem (op0);
  9589.       op1 = force_not_mem (op1);
  9590.     }
  9591.  
  9592.   do_pending_stack_adjust ();
  9593.  
  9594.   if (GET_CODE (op0) == CONST_INT && GET_CODE (op1) == CONST_INT
  9595.       && (tem = simplify_relational_operation (code, mode, op0, op1)) != 0)
  9596.     return tem;
  9597.  
  9598. #if 0
  9599.   /* There's no need to do this now that combine.c can eliminate lots of
  9600.      sign extensions.  This can be less efficient in certain cases on other
  9601.      machines. */
  9602.  
  9603.   /* If this is a signed equality comparison, we can do it as an
  9604.      unsigned comparison since zero-extension is cheaper than sign
  9605.      extension and comparisons with zero are done as unsigned.  This is
  9606.      the case even on machines that can do fast sign extension, since
  9607.      zero-extension is easier to combine with other operations than
  9608.      sign-extension is.  If we are comparing against a constant, we must
  9609.      convert it to what it would look like unsigned.  */
  9610.   if ((code == EQ || code == NE) && ! unsignedp
  9611.       && GET_MODE_BITSIZE (GET_MODE (op0)) <= HOST_BITS_PER_WIDE_INT)
  9612.     {
  9613.       if (GET_CODE (op1) == CONST_INT
  9614.       && (INTVAL (op1) & GET_MODE_MASK (GET_MODE (op0))) != INTVAL (op1))
  9615.     op1 = GEN_INT (INTVAL (op1) & GET_MODE_MASK (GET_MODE (op0)));
  9616.       unsignedp = 1;
  9617.     }
  9618. #endif
  9619.     
  9620.   emit_cmp_insn (op0, op1, code, size, mode, unsignedp, align);
  9621.  
  9622.   return gen_rtx (code, VOIDmode, cc0_rtx, const0_rtx);
  9623. }
  9624.  
  9625. /* Generate code to calculate EXP using a store-flag instruction
  9626.    and return an rtx for the result.  EXP is either a comparison
  9627.    or a TRUTH_NOT_EXPR whose operand is a comparison.
  9628.  
  9629.    If TARGET is nonzero, store the result there if convenient.
  9630.  
  9631.    If ONLY_CHEAP is non-zero, only do this if it is likely to be very
  9632.    cheap.
  9633.  
  9634.    Return zero if there is no suitable set-flag instruction
  9635.    available on this machine.
  9636.  
  9637.    Once expand_expr has been called on the arguments of the comparison,
  9638.    we are committed to doing the store flag, since it is not safe to
  9639.    re-evaluate the expression.  We emit the store-flag insn by calling
  9640.    emit_store_flag, but only expand the arguments if we have a reason
  9641.    to believe that emit_store_flag will be successful.  If we think that
  9642.    it will, but it isn't, we have to simulate the store-flag with a
  9643.    set/jump/set sequence.  */
  9644.  
  9645. static rtx
  9646. do_store_flag (exp, target, mode, only_cheap)
  9647.      tree exp;
  9648.      rtx target;
  9649.      enum machine_mode mode;
  9650.      int only_cheap;
  9651. {
  9652.   enum rtx_code code;
  9653.   tree arg0, arg1, type;
  9654.   tree tem;
  9655.   enum machine_mode operand_mode;
  9656.   int invert = 0;
  9657.   int unsignedp;
  9658.   rtx op0, op1;
  9659.   enum insn_code icode;
  9660.   rtx subtarget = target;
  9661.   rtx result, label, pattern, jump_pat;
  9662.  
  9663.   /* If this is a TRUTH_NOT_EXPR, set a flag indicating we must invert the
  9664.      result at the end.  We can't simply invert the test since it would
  9665.      have already been inverted if it were valid.  This case occurs for
  9666.      some floating-point comparisons.  */
  9667.  
  9668.   if (TREE_CODE (exp) == TRUTH_NOT_EXPR)
  9669.     invert = 1, exp = TREE_OPERAND (exp, 0);
  9670.  
  9671.   arg0 = TREE_OPERAND (exp, 0);
  9672.   arg1 = TREE_OPERAND (exp, 1);
  9673.   type = TREE_TYPE (arg0);
  9674.   operand_mode = TYPE_MODE (type);
  9675.   unsignedp = TREE_UNSIGNED (type);
  9676.  
  9677.   /* We won't bother with BLKmode store-flag operations because it would mean
  9678.      passing a lot of information to emit_store_flag.  */
  9679.   if (operand_mode == BLKmode)
  9680.     return 0;
  9681.  
  9682.   STRIP_NOPS (arg0);
  9683.   STRIP_NOPS (arg1);
  9684.  
  9685.   /* Get the rtx comparison code to use.  We know that EXP is a comparison
  9686.      operation of some type.  Some comparisons against 1 and -1 can be
  9687.      converted to comparisons with zero.  Do so here so that the tests
  9688.      below will be aware that we have a comparison with zero.   These
  9689.      tests will not catch constants in the first operand, but constants
  9690.      are rarely passed as the first operand.  */
  9691.  
  9692.   switch (TREE_CODE (exp))
  9693.     {
  9694.     case EQ_EXPR:
  9695.       code = EQ;
  9696.       break;
  9697.     case NE_EXPR:
  9698.       code = NE;
  9699.       break;
  9700.     case LT_EXPR:
  9701.       if (integer_onep (arg1))
  9702.     arg1 = integer_zero_node, code = unsignedp ? LEU : LE;
  9703.       else
  9704.     code = unsignedp ? LTU : LT;
  9705.       break;
  9706.     case LE_EXPR:
  9707.       if (! unsignedp && integer_all_onesp (arg1))
  9708.     arg1 = integer_zero_node, code = LT;
  9709.       else
  9710.     code = unsignedp ? LEU : LE;
  9711.       break;
  9712.     case GT_EXPR:
  9713.       if (! unsignedp && integer_all_onesp (arg1))
  9714.     arg1 = integer_zero_node, code = GE;
  9715.       else
  9716.     code = unsignedp ? GTU : GT;
  9717.       break;
  9718.     case GE_EXPR:
  9719.       if (integer_onep (arg1))
  9720.     arg1 = integer_zero_node, code = unsignedp ? GTU : GT;
  9721.       else
  9722.     code = unsignedp ? GEU : GE;
  9723.       break;
  9724.     default:
  9725.       abort ();
  9726.     }
  9727.  
  9728.   /* Put a constant second.  */
  9729.   if (TREE_CODE (arg0) == REAL_CST || TREE_CODE (arg0) == INTEGER_CST)
  9730.     {
  9731.       tem = arg0; arg0 = arg1; arg1 = tem;
  9732.       code = swap_condition (code);
  9733.     }
  9734.  
  9735.   /* If this is an equality or inequality test of a single bit, we can
  9736.      do this by shifting the bit being tested to the low-order bit and
  9737.      masking the result with the constant 1.  If the condition was EQ,
  9738.      we xor it with 1.  This does not require an scc insn and is faster
  9739.      than an scc insn even if we have it.  */
  9740.  
  9741.   if ((code == NE || code == EQ)
  9742.       && TREE_CODE (arg0) == BIT_AND_EXPR && integer_zerop (arg1)
  9743.       && integer_pow2p (TREE_OPERAND (arg0, 1))
  9744.       && TYPE_PRECISION (type) <= HOST_BITS_PER_WIDE_INT)
  9745.     {
  9746.       tree inner = TREE_OPERAND (arg0, 0);
  9747.       int bitnum = exact_log2 (INTVAL (expand_expr (TREE_OPERAND (arg0, 1),
  9748.                             NULL_RTX, VOIDmode, 0)));
  9749.       int ops_unsignedp;
  9750.  
  9751.       /* If INNER is a right shift of a constant and it plus BITNUM does
  9752.      not overflow, adjust BITNUM and INNER.  */
  9753.  
  9754.       if (TREE_CODE (inner) == RSHIFT_EXPR
  9755.       && TREE_CODE (TREE_OPERAND (inner, 1)) == INTEGER_CST
  9756.       && TREE_INT_CST_HIGH (TREE_OPERAND (inner, 1)) == 0
  9757.       && (bitnum + TREE_INT_CST_LOW (TREE_OPERAND (inner, 1))
  9758.           < TYPE_PRECISION (type)))
  9759.     {
  9760.       bitnum +=TREE_INT_CST_LOW (TREE_OPERAND (inner, 1));
  9761.       inner = TREE_OPERAND (inner, 0);
  9762.     }
  9763.  
  9764.       /* If we are going to be able to omit the AND below, we must do our
  9765.      operations as unsigned.  If we must use the AND, we have a choice.
  9766.      Normally unsigned is faster, but for some machines signed is.  */
  9767.       ops_unsignedp = (bitnum == TYPE_PRECISION (type) - 1 ? 1
  9768. #ifdef LOAD_EXTEND_OP
  9769.                : (LOAD_EXTEND_OP (operand_mode) == SIGN_EXTEND ? 0 : 1)
  9770. #else
  9771.                : 1
  9772. #endif
  9773.                );
  9774.  
  9775.       if (subtarget == 0 || GET_CODE (subtarget) != REG
  9776.       || GET_MODE (subtarget) != operand_mode
  9777.       || ! safe_from_p (subtarget, inner))
  9778.     subtarget = 0;
  9779.  
  9780.       op0 = expand_expr (inner, subtarget, VOIDmode, 0);
  9781.  
  9782.       if (bitnum != 0)
  9783.     op0 = expand_shift (RSHIFT_EXPR, GET_MODE (op0), op0,
  9784.                 size_int (bitnum), subtarget, ops_unsignedp);
  9785.  
  9786.       if (GET_MODE (op0) != mode)
  9787.     op0 = convert_to_mode (mode, op0, ops_unsignedp);
  9788.  
  9789.       if ((code == EQ && ! invert) || (code == NE && invert))
  9790.     op0 = expand_binop (mode, xor_optab, op0, const1_rtx, subtarget,
  9791.                 ops_unsignedp, OPTAB_LIB_WIDEN);
  9792.  
  9793.       /* Put the AND last so it can combine with more things.  */
  9794.       if (bitnum != TYPE_PRECISION (type) - 1)
  9795.     op0 = expand_and (op0, const1_rtx, subtarget);
  9796.  
  9797.       return op0;
  9798.     }
  9799.  
  9800.   /* Now see if we are likely to be able to do this.  Return if not.  */
  9801.   if (! can_compare_p (operand_mode))
  9802.     return 0;
  9803.   icode = setcc_gen_code[(int) code];
  9804.   if (icode == CODE_FOR_nothing
  9805.       || (only_cheap && insn_operand_mode[(int) icode][0] != mode))
  9806.     {
  9807.       /* We can only do this if it is one of the special cases that
  9808.      can be handled without an scc insn.  */
  9809.       if ((code == LT && integer_zerop (arg1))
  9810.       || (! only_cheap && code == GE && integer_zerop (arg1)))
  9811.     ;
  9812.       else if (BRANCH_COST >= 0
  9813.            && ! only_cheap && (code == NE || code == EQ)
  9814.            && TREE_CODE (type) != REAL_TYPE
  9815.            && ((abs_optab->handlers[(int) operand_mode].insn_code
  9816.             != CODE_FOR_nothing)
  9817.            || (ffs_optab->handlers[(int) operand_mode].insn_code
  9818.                != CODE_FOR_nothing)))
  9819.     ;
  9820.       else
  9821.     return 0;
  9822.     }
  9823.       
  9824.   preexpand_calls (exp);
  9825.   if (subtarget == 0 || GET_CODE (subtarget) != REG
  9826.       || GET_MODE (subtarget) != operand_mode
  9827.       || ! safe_from_p (subtarget, arg1))
  9828.     subtarget = 0;
  9829.  
  9830.   op0 = expand_expr (arg0, subtarget, VOIDmode, 0);
  9831.   op1 = expand_expr (arg1, NULL_RTX, VOIDmode, 0);
  9832.  
  9833.   if (target == 0)
  9834.     target = gen_reg_rtx (mode);
  9835.  
  9836.   /* Pass copies of OP0 and OP1 in case they contain a QUEUED.  This is safe
  9837.      because, if the emit_store_flag does anything it will succeed and
  9838.      OP0 and OP1 will not be used subsequently.  */
  9839.  
  9840.   result = emit_store_flag (target, code,
  9841.                 queued_subexp_p (op0) ? copy_rtx (op0) : op0,
  9842.                 queued_subexp_p (op1) ? copy_rtx (op1) : op1,
  9843.                 operand_mode, unsignedp, 1);
  9844.  
  9845.   if (result)
  9846.     {
  9847.       if (invert)
  9848.     result = expand_binop (mode, xor_optab, result, const1_rtx,
  9849.                    result, 0, OPTAB_LIB_WIDEN);
  9850.       return result;
  9851.     }
  9852.  
  9853.   /* If this failed, we have to do this with set/compare/jump/set code.  */
  9854.   if (target == 0 || GET_CODE (target) != REG
  9855.       || reg_mentioned_p (target, op0) || reg_mentioned_p (target, op1))
  9856.     target = gen_reg_rtx (GET_MODE (target));
  9857.  
  9858.   emit_move_insn (target, invert ? const0_rtx : const1_rtx);
  9859.   result = compare_from_rtx (op0, op1, code, unsignedp,
  9860.                  operand_mode, NULL_RTX, 0);
  9861.   if (GET_CODE (result) == CONST_INT)
  9862.     return (((result == const0_rtx && ! invert)
  9863.          || (result != const0_rtx && invert))
  9864.         ? const0_rtx : const1_rtx);
  9865.  
  9866.   label = gen_label_rtx ();
  9867.   if (bcc_gen_fctn[(int) code] == 0)
  9868.     abort ();
  9869.  
  9870.   emit_jump_insn ((*bcc_gen_fctn[(int) code]) (label));
  9871.   emit_move_insn (target, invert ? const1_rtx : const0_rtx);
  9872.   emit_label (label);
  9873.  
  9874.   return target;
  9875. }
  9876.  
  9877. /* Generate a tablejump instruction (used for switch statements).  */
  9878.  
  9879. #ifdef HAVE_tablejump
  9880.  
  9881. /* INDEX is the value being switched on, with the lowest value
  9882.    in the table already subtracted.
  9883.    MODE is its expected mode (needed if INDEX is constant).
  9884.    RANGE is the length of the jump table.
  9885.    TABLE_LABEL is a CODE_LABEL rtx for the table itself.
  9886.  
  9887.    DEFAULT_LABEL is a CODE_LABEL rtx to jump to if the
  9888.    index value is out of range.  */
  9889.  
  9890. void
  9891. do_tablejump (index, mode, range, table_label, default_label)
  9892.      rtx index, range, table_label, default_label;
  9893.      enum machine_mode mode;
  9894. {
  9895.   register rtx temp, vector;
  9896.  
  9897.   /* Do an unsigned comparison (in the proper mode) between the index
  9898.      expression and the value which represents the length of the range.
  9899.      Since we just finished subtracting the lower bound of the range
  9900.      from the index expression, this comparison allows us to simultaneously
  9901.      check that the original index expression value is both greater than
  9902.      or equal to the minimum value of the range and less than or equal to
  9903.      the maximum value of the range.  */
  9904.  
  9905.   emit_cmp_insn (index, range, GTU, NULL_RTX, mode, 1, 0);
  9906.   emit_jump_insn (gen_bgtu (default_label));
  9907.  
  9908.   /* If index is in range, it must fit in Pmode.
  9909.      Convert to Pmode so we can index with it.  */
  9910.   if (mode != Pmode)
  9911.     index = convert_to_mode (Pmode, index, 1);
  9912.  
  9913.   /* Don't let a MEM slip thru, because then INDEX that comes
  9914.      out of PIC_CASE_VECTOR_ADDRESS won't be a valid address,
  9915.      and break_out_memory_refs will go to work on it and mess it up.  */
  9916. #ifdef PIC_CASE_VECTOR_ADDRESS
  9917.   if (flag_pic && GET_CODE (index) != REG)
  9918.     index = copy_to_mode_reg (Pmode, index);
  9919. #endif
  9920.  
  9921.   /* If flag_force_addr were to affect this address
  9922.      it could interfere with the tricky assumptions made
  9923.      about addresses that contain label-refs,
  9924.      which may be valid only very near the tablejump itself.  */
  9925.   /* ??? The only correct use of CASE_VECTOR_MODE is the one inside the
  9926.      GET_MODE_SIZE, because this indicates how large insns are.  The other
  9927.      uses should all be Pmode, because they are addresses.  This code
  9928.      could fail if addresses and insns are not the same size.  */
  9929.   index = gen_rtx (PLUS, Pmode,
  9930.            gen_rtx (MULT, Pmode, index,
  9931.                 GEN_INT (GET_MODE_SIZE (CASE_VECTOR_MODE))),
  9932.            gen_rtx (LABEL_REF, Pmode, table_label));
  9933. #ifdef PIC_CASE_VECTOR_ADDRESS
  9934.   if (flag_pic)
  9935.     index = PIC_CASE_VECTOR_ADDRESS (index);
  9936.   else
  9937. #endif
  9938.     index = memory_address_noforce (CASE_VECTOR_MODE, index);
  9939.   temp = gen_reg_rtx (CASE_VECTOR_MODE);
  9940.   vector = gen_rtx (MEM, CASE_VECTOR_MODE, index);
  9941.   RTX_UNCHANGING_P (vector) = 1;
  9942.   convert_move (temp, vector, 0);
  9943.  
  9944.   emit_jump_insn (gen_tablejump (temp, table_label));
  9945.  
  9946. #ifndef CASE_VECTOR_PC_RELATIVE
  9947.   /* If we are generating PIC code or if the table is PC-relative, the
  9948.      table and JUMP_INSN must be adjacent, so don't output a BARRIER.  */
  9949.   if (! flag_pic)
  9950.     emit_barrier ();
  9951. #endif
  9952. }
  9953.  
  9954. #endif /* HAVE_tablejump */
  9955.  
  9956.  
  9957. /* Emit a suitable bytecode to load a value from memory, assuming a pointer
  9958.    to that value is on the top of the stack. The resulting type is TYPE, and
  9959.    the source declaration is DECL. */
  9960.  
  9961. void
  9962. bc_load_memory (type, decl)
  9963.      tree type, decl;
  9964. {
  9965.   enum bytecode_opcode opcode;
  9966.   
  9967.   
  9968.   /* Bit fields are special.  We only know about signed and
  9969.      unsigned ints, and enums.  The latter are treated as
  9970.      signed integers. */
  9971.   
  9972.   if (DECL_BIT_FIELD (decl))
  9973.     if (TREE_CODE (type) == ENUMERAL_TYPE
  9974.     || TREE_CODE (type) == INTEGER_TYPE)
  9975.       opcode = TREE_UNSIGNED (type) ? zxloadBI : sxloadBI;
  9976.     else
  9977.       abort ();
  9978.   else
  9979.     /* See corresponding comment in bc_store_memory(). */
  9980.     if (TYPE_MODE (type) == BLKmode
  9981.     || TYPE_MODE (type) == VOIDmode)
  9982.       return;
  9983.     else
  9984.       opcode = mode_to_load_map [(int) TYPE_MODE (type)];
  9985.  
  9986.   if (opcode == neverneverland)
  9987.     abort ();
  9988.   
  9989.   bc_emit_bytecode (opcode);
  9990.   
  9991. #ifdef DEBUG_PRINT_CODE
  9992.   fputc ('\n', stderr);
  9993. #endif
  9994. }
  9995.  
  9996.  
  9997. /* Store the contents of the second stack slot to the address in the
  9998.    top stack slot.  DECL is the declaration of the destination and is used
  9999.    to determine whether we're dealing with a bitfield. */
  10000.  
  10001. void
  10002. bc_store_memory (type, decl)
  10003.      tree type, decl;
  10004. {
  10005.   enum bytecode_opcode opcode;
  10006.   
  10007.   
  10008.   if (DECL_BIT_FIELD (decl))
  10009.     {
  10010.       if (TREE_CODE (type) == ENUMERAL_TYPE
  10011.       || TREE_CODE (type) == INTEGER_TYPE)
  10012.     opcode = sstoreBI;
  10013.       else
  10014.     abort ();
  10015.     }
  10016.   else
  10017.     if (TYPE_MODE (type) == BLKmode)
  10018.       {
  10019.     /* Copy structure.  This expands to a block copy instruction, storeBLK.
  10020.        In addition to the arguments expected by the other store instructions,
  10021.        it also expects a type size (SImode) on top of the stack, which is the
  10022.        structure size in size units (usually bytes).  The two first arguments
  10023.        are already on the stack; so we just put the size on level 1.  For some
  10024.        other languages, the size may be variable, this is why we don't encode
  10025.        it as a storeBLK literal, but rather treat it as a full-fledged expression. */
  10026.     
  10027.     bc_expand_expr (TYPE_SIZE (type));
  10028.     opcode = storeBLK;
  10029.       }
  10030.     else
  10031.       opcode = mode_to_store_map [(int) TYPE_MODE (type)];
  10032.  
  10033.   if (opcode == neverneverland)
  10034.     abort ();
  10035.  
  10036.   bc_emit_bytecode (opcode);
  10037.   
  10038. #ifdef DEBUG_PRINT_CODE
  10039.   fputc ('\n', stderr);
  10040. #endif
  10041. }
  10042.  
  10043.  
  10044. /* Allocate local stack space sufficient to hold a value of the given
  10045.    SIZE at alignment boundary ALIGNMENT bits.  ALIGNMENT must be an
  10046.    integral power of 2.  A special case is locals of type VOID, which
  10047.    have size 0 and alignment 1 - any "voidish" SIZE or ALIGNMENT is
  10048.    remapped into the corresponding attribute of SI.  */
  10049.  
  10050. rtx
  10051. bc_allocate_local (size, alignment)
  10052.      int size, alignment;
  10053. {
  10054.   rtx retval;
  10055.   int byte_alignment;
  10056.  
  10057.   if (size < 0)
  10058.     abort ();
  10059.  
  10060.   /* Normalize size and alignment  */
  10061.   if (!size)
  10062.     size = UNITS_PER_WORD;
  10063.  
  10064.   if (alignment < BITS_PER_UNIT)
  10065.     byte_alignment = 1 << (INT_ALIGN - 1);
  10066.   else
  10067.     /* Align */
  10068.     byte_alignment = alignment / BITS_PER_UNIT;
  10069.  
  10070.   if (local_vars_size & (byte_alignment - 1))
  10071.     local_vars_size += byte_alignment - (local_vars_size & (byte_alignment - 1));
  10072.  
  10073.   retval = bc_gen_rtx ((char *) 0, local_vars_size, (struct bc_label *) 0);
  10074.   local_vars_size += size;
  10075.  
  10076.   return retval;
  10077. }
  10078.  
  10079.  
  10080. /* Allocate variable-sized local array. Variable-sized arrays are
  10081.    actually pointers to the address in memory where they are stored. */
  10082.  
  10083. rtx
  10084. bc_allocate_variable_array (size)
  10085.      tree size;
  10086. {
  10087.   rtx retval;
  10088.   const int ptralign = (1 << (PTR_ALIGN - 1));
  10089.  
  10090.   /* Align pointer */
  10091.   if (local_vars_size & ptralign)
  10092.     local_vars_size +=  ptralign - (local_vars_size & ptralign);
  10093.  
  10094.   /* Note down local space needed: pointer to block; also return
  10095.      dummy rtx */
  10096.  
  10097.   retval = bc_gen_rtx ((char *) 0, local_vars_size, (struct bc_label *) 0);
  10098.   local_vars_size += POINTER_SIZE / BITS_PER_UNIT;
  10099.   return retval;
  10100. }
  10101.  
  10102.  
  10103. /* Push the machine address for the given external variable offset.  */
  10104. void
  10105. bc_load_externaddr (externaddr)
  10106.      rtx externaddr;
  10107. {
  10108.   bc_emit_bytecode (constP);
  10109.   bc_emit_code_labelref (BYTECODE_LABEL (externaddr),
  10110.              BYTECODE_BC_LABEL (externaddr)->offset);
  10111.  
  10112. #ifdef DEBUG_PRINT_CODE
  10113.   fputc ('\n', stderr);
  10114. #endif
  10115. }
  10116.  
  10117.  
  10118. static char *
  10119. bc_strdup (s)
  10120.     char *s;
  10121. {
  10122.   char *new = (char *) xmalloc ((strlen (s) + 1) * sizeof *s);
  10123.   strcpy (new, s);
  10124.   return new;
  10125. }
  10126.  
  10127.  
  10128. /* Like above, but expects an IDENTIFIER.  */
  10129. void
  10130. bc_load_externaddr_id (id, offset)
  10131.      tree id;
  10132.      int offset;
  10133. {
  10134.   if (!IDENTIFIER_POINTER (id))
  10135.     abort ();
  10136.  
  10137.   bc_emit_bytecode (constP);
  10138.   bc_emit_code_labelref (bc_xstrdup (IDENTIFIER_POINTER (id)), offset);
  10139.  
  10140. #ifdef DEBUG_PRINT_CODE
  10141.   fputc ('\n', stderr);
  10142. #endif
  10143. }
  10144.  
  10145.  
  10146. /* Push the machine address for the given local variable offset.  */
  10147. void
  10148. bc_load_localaddr (localaddr)
  10149.      rtx localaddr;
  10150. {
  10151.   bc_emit_instruction (localP, (HOST_WIDE_INT) BYTECODE_BC_LABEL (localaddr)->offset);
  10152. }
  10153.  
  10154.  
  10155. /* Push the machine address for the given parameter offset.
  10156.    NOTE: offset is in bits. */
  10157. void
  10158. bc_load_parmaddr (parmaddr)
  10159.      rtx parmaddr;
  10160. {
  10161.   bc_emit_instruction (argP, ((HOST_WIDE_INT) BYTECODE_BC_LABEL (parmaddr)->offset
  10162.                   / BITS_PER_UNIT));
  10163. }
  10164.  
  10165.  
  10166. /* Convert a[i] into *(a + i).  */
  10167. tree
  10168. bc_canonicalize_array_ref (exp)
  10169.      tree exp;
  10170. {
  10171.   tree type = TREE_TYPE (exp);
  10172.   tree array_adr = build1 (ADDR_EXPR, TYPE_POINTER_TO (type),
  10173.                TREE_OPERAND (exp, 0));
  10174.   tree index = TREE_OPERAND (exp, 1);
  10175.  
  10176.  
  10177.   /* Convert the integer argument to a type the same size as a pointer
  10178.      so the multiply won't overflow spuriously.  */
  10179.  
  10180.   if (TYPE_PRECISION (TREE_TYPE (index)) != POINTER_SIZE)
  10181.     index = convert (type_for_size (POINTER_SIZE, 0), index);
  10182.  
  10183.   /* The array address isn't volatile even if the array is.
  10184.      (Of course this isn't terribly relevant since the bytecode
  10185.      translator treats nearly everything as volatile anyway.)  */
  10186.   TREE_THIS_VOLATILE (array_adr) = 0;
  10187.  
  10188.   return build1 (INDIRECT_REF, type,
  10189.          fold (build (PLUS_EXPR,
  10190.                   TYPE_POINTER_TO (type),
  10191.                   array_adr,
  10192.                   fold (build (MULT_EXPR,
  10193.                        TYPE_POINTER_TO (type),
  10194.                        index,
  10195.                        size_in_bytes (type))))));
  10196. }
  10197.  
  10198.  
  10199. /* Load the address of the component referenced by the given
  10200.    COMPONENT_REF expression.
  10201.  
  10202.    Returns innermost lvalue. */
  10203.  
  10204. tree
  10205. bc_expand_component_address (exp)
  10206.      tree exp;
  10207. {
  10208.   tree tem, chain;
  10209.   enum machine_mode mode;
  10210.   int bitpos = 0;
  10211.   HOST_WIDE_INT SIval;
  10212.  
  10213.  
  10214.   tem = TREE_OPERAND (exp, 1);
  10215.   mode = DECL_MODE (tem);
  10216.  
  10217.  
  10218.   /* Compute cumulative bit offset for nested component refs
  10219.      and array refs, and find the ultimate containing object.  */
  10220.  
  10221.   for (tem = exp;; tem = TREE_OPERAND (tem, 0))
  10222.     {
  10223.       if (TREE_CODE (tem) == COMPONENT_REF)
  10224.     bitpos += TREE_INT_CST_LOW (DECL_FIELD_BITPOS (TREE_OPERAND (tem, 1)));
  10225.       else
  10226.     if (TREE_CODE (tem) == ARRAY_REF
  10227.         && TREE_CODE (TREE_OPERAND (tem, 1)) == INTEGER_CST
  10228.         && TREE_CODE (TYPE_SIZE (TREE_TYPE (tem))) == INTEGER_CST)
  10229.  
  10230.       bitpos += (TREE_INT_CST_LOW (TREE_OPERAND (tem, 1))
  10231.              * TREE_INT_CST_LOW (TYPE_SIZE (TREE_TYPE (tem)))
  10232.              /* * TYPE_SIZE_UNIT (TREE_TYPE (tem)) */);
  10233.     else
  10234.       break;
  10235.     }
  10236.  
  10237.   bc_expand_expr (tem);
  10238.  
  10239.  
  10240.   /* For bitfields also push their offset and size */
  10241.   if (DECL_BIT_FIELD (TREE_OPERAND (exp, 1)))
  10242.     bc_push_offset_and_size (bitpos, /* DECL_SIZE_UNIT */ (TREE_OPERAND (exp, 1)));
  10243.   else
  10244.     if (SIval = bitpos / BITS_PER_UNIT)
  10245.       bc_emit_instruction (addconstPSI, SIval);
  10246.  
  10247.   return (TREE_OPERAND (exp, 1));
  10248. }
  10249.  
  10250.  
  10251. /* Emit code to push two SI constants */
  10252. void
  10253. bc_push_offset_and_size (offset, size)
  10254.      HOST_WIDE_INT offset, size;
  10255. {
  10256.   bc_emit_instruction (constSI, offset);
  10257.   bc_emit_instruction (constSI, size);
  10258. }
  10259.  
  10260.  
  10261. /* Emit byte code to push the address of the given lvalue expression to
  10262.    the stack.  If it's a bit field, we also push offset and size info.
  10263.  
  10264.    Returns innermost component, which allows us to determine not only
  10265.    its type, but also whether it's a bitfield. */
  10266.  
  10267. tree
  10268. bc_expand_address (exp)
  10269.      tree exp;
  10270. {
  10271.   /* Safeguard */
  10272.   if (!exp || TREE_CODE (exp) == ERROR_MARK)
  10273.     return (exp);
  10274.  
  10275.  
  10276.   switch (TREE_CODE (exp))
  10277.     {
  10278.     case ARRAY_REF:
  10279.  
  10280.       return (bc_expand_address (bc_canonicalize_array_ref (exp)));
  10281.  
  10282.     case COMPONENT_REF:
  10283.  
  10284.       return (bc_expand_component_address (exp));
  10285.  
  10286.     case INDIRECT_REF:
  10287.  
  10288.       bc_expand_expr (TREE_OPERAND (exp, 0));
  10289.  
  10290.       /* For variable-sized types: retrieve pointer.  Sometimes the
  10291.      TYPE_SIZE tree is NULL.  Is this a bug or a feature?  Let's
  10292.      also make sure we have an operand, just in case... */
  10293.  
  10294.       if (TREE_OPERAND (exp, 0)
  10295.       && TYPE_SIZE (TREE_TYPE (TREE_OPERAND (exp, 0)))
  10296.       && TREE_CODE (TYPE_SIZE (TREE_TYPE (TREE_OPERAND (exp, 0)))) != INTEGER_CST)
  10297.     bc_emit_instruction (loadP);
  10298.  
  10299.       /* If packed, also return offset and size */
  10300.       if (DECL_BIT_FIELD (TREE_OPERAND (exp, 0)))
  10301.     
  10302.     bc_push_offset_and_size (TREE_INT_CST_LOW (DECL_FIELD_BITPOS (TREE_OPERAND (exp, 0))),
  10303.                  TREE_INT_CST_LOW (DECL_SIZE (TREE_OPERAND (exp, 0))));
  10304.  
  10305.       return (TREE_OPERAND (exp, 0));
  10306.  
  10307.     case FUNCTION_DECL:
  10308.  
  10309.       bc_load_externaddr_id (DECL_ASSEMBLER_NAME (exp),
  10310.                  BYTECODE_BC_LABEL (DECL_RTL (exp))->offset);
  10311.       break;
  10312.  
  10313.     case PARM_DECL:
  10314.  
  10315.       bc_load_parmaddr (DECL_RTL (exp));
  10316.  
  10317.       /* For variable-sized types: retrieve pointer */
  10318.       if (TYPE_SIZE (TREE_TYPE (exp))
  10319.       && TREE_CODE (TYPE_SIZE (TREE_TYPE (exp))) != INTEGER_CST)
  10320.     bc_emit_instruction (loadP);
  10321.  
  10322.       /* If packed, also return offset and size */
  10323.       if (DECL_BIT_FIELD (exp))
  10324.     bc_push_offset_and_size (TREE_INT_CST_LOW (DECL_FIELD_BITPOS (exp)),
  10325.                  TREE_INT_CST_LOW (DECL_SIZE (exp)));
  10326.  
  10327.       break;
  10328.  
  10329.     case RESULT_DECL:
  10330.  
  10331.       bc_emit_instruction (returnP);
  10332.       break;
  10333.  
  10334.     case VAR_DECL:
  10335.  
  10336. #if 0
  10337.       if (BYTECODE_LABEL (DECL_RTL (exp)))
  10338.     bc_load_externaddr (DECL_RTL (exp));
  10339. #endif
  10340.  
  10341.       if (DECL_EXTERNAL (exp))
  10342.     bc_load_externaddr_id (DECL_ASSEMBLER_NAME (exp),
  10343.                    (BYTECODE_BC_LABEL (DECL_RTL (exp)))->offset);
  10344.       else
  10345.     bc_load_localaddr (DECL_RTL (exp));
  10346.  
  10347.       /* For variable-sized types: retrieve pointer */
  10348.       if (TYPE_SIZE (TREE_TYPE (exp))
  10349.       && TREE_CODE (TYPE_SIZE (TREE_TYPE (exp))) != INTEGER_CST)
  10350.     bc_emit_instruction (loadP);
  10351.  
  10352.       /* If packed, also return offset and size */
  10353.       if (DECL_BIT_FIELD (exp))
  10354.     bc_push_offset_and_size (TREE_INT_CST_LOW (DECL_FIELD_BITPOS (exp)),
  10355.                  TREE_INT_CST_LOW (DECL_SIZE (exp)));
  10356.       
  10357.       break;
  10358.  
  10359.     case STRING_CST:
  10360.       {
  10361.     rtx r;
  10362.     
  10363.     bc_emit_bytecode (constP);
  10364.     r = output_constant_def (exp);
  10365.     bc_emit_code_labelref (BYTECODE_LABEL (r), BYTECODE_BC_LABEL (r)->offset);
  10366.  
  10367. #ifdef DEBUG_PRINT_CODE
  10368.     fputc ('\n', stderr);
  10369. #endif
  10370.       }
  10371.       break;
  10372.  
  10373.     default:
  10374.  
  10375.       abort();
  10376.       break;
  10377.     }
  10378.  
  10379.   /* Most lvalues don't have components. */
  10380.   return (exp);
  10381. }
  10382.  
  10383.  
  10384. /* Emit a type code to be used by the runtime support in handling
  10385.    parameter passing.   The type code consists of the machine mode
  10386.    plus the minimal alignment shifted left 8 bits.  */
  10387.  
  10388. tree
  10389. bc_runtime_type_code (type)
  10390.      tree type;
  10391. {
  10392.   int val;
  10393.  
  10394.   switch (TREE_CODE (type))
  10395.     {
  10396.     case VOID_TYPE:
  10397.     case INTEGER_TYPE:
  10398.     case REAL_TYPE:
  10399.     case COMPLEX_TYPE:
  10400.     case ENUMERAL_TYPE:
  10401.     case POINTER_TYPE:
  10402.     case RECORD_TYPE:
  10403.  
  10404.       val = (int) TYPE_MODE (type) | TYPE_ALIGN (type) << 8;
  10405.       break;
  10406.  
  10407.     case ERROR_MARK:
  10408.  
  10409.       val = 0;
  10410.       break;
  10411.  
  10412.     default:
  10413.  
  10414.       abort ();
  10415.     }
  10416.   return build_int_2 (val, 0);
  10417. }
  10418.  
  10419.  
  10420. /* Generate constructor label */
  10421. char *
  10422. bc_gen_constr_label ()
  10423. {
  10424.   static int label_counter;
  10425.   static char label[20];
  10426.  
  10427.   sprintf (label, "*LR%d", label_counter++);
  10428.  
  10429.   return (obstack_copy0 (&permanent_obstack, label, strlen (label)));
  10430. }
  10431.  
  10432.  
  10433. /* Evaluate constructor CONSTR and return pointer to it on level one.  We
  10434.    expand the constructor data as static data, and push a pointer to it.
  10435.    The pointer is put in the pointer table and is retrieved by a constP
  10436.    bytecode instruction.  We then loop and store each constructor member in
  10437.    the corresponding component.  Finally, we return the original pointer on
  10438.    the stack. */
  10439.  
  10440. void
  10441. bc_expand_constructor (constr)
  10442.      tree constr;
  10443. {
  10444.   char *l;
  10445.   HOST_WIDE_INT ptroffs;
  10446.   rtx constr_rtx;
  10447.  
  10448.   
  10449.   /* Literal constructors are handled as constants, whereas
  10450.      non-literals are evaluated and stored element by element
  10451.      into the data segment. */
  10452.   
  10453.   /* Allocate space in proper segment and push pointer to space on stack.
  10454.    */
  10455.  
  10456.   l = bc_gen_constr_label ();
  10457.  
  10458.   if (TREE_CONSTANT (constr))
  10459.     {
  10460.       text_section ();
  10461.  
  10462.       bc_emit_const_labeldef (l);
  10463.       bc_output_constructor (constr, int_size_in_bytes (TREE_TYPE (constr)));
  10464.     }
  10465.   else
  10466.     {
  10467.       data_section ();
  10468.  
  10469.       bc_emit_data_labeldef (l);
  10470.       bc_output_data_constructor (constr);
  10471.     }
  10472.  
  10473.   
  10474.   /* Add reference to pointer table and recall pointer to stack;
  10475.      this code is common for both types of constructors: literals
  10476.      and non-literals. */
  10477.  
  10478.   ptroffs = bc_define_pointer (l);
  10479.   bc_emit_instruction (constP, ptroffs);
  10480.  
  10481.   /* This is all that has to be done if it's a literal. */
  10482.   if (TREE_CONSTANT (constr))
  10483.     return;
  10484.  
  10485.  
  10486.   /* At this point, we have the pointer to the structure on top of the stack.
  10487.      Generate sequences of store_memory calls for the constructor. */
  10488.   
  10489.   /* constructor type is structure */
  10490.   if (TREE_CODE (TREE_TYPE (constr)) == RECORD_TYPE)
  10491.     {
  10492.       register tree elt;
  10493.       
  10494.       /* If the constructor has fewer fields than the structure,
  10495.      clear the whole structure first.  */
  10496.       
  10497.       if (list_length (CONSTRUCTOR_ELTS (constr))
  10498.       != list_length (TYPE_FIELDS (TREE_TYPE (constr))))
  10499.     {
  10500.       bc_emit_instruction (duplicate);
  10501.       bc_emit_instruction (constSI, (HOST_WIDE_INT) int_size_in_bytes (TREE_TYPE (constr)));
  10502.       bc_emit_instruction (clearBLK);
  10503.     }
  10504.       
  10505.       /* Store each element of the constructor into the corresponding
  10506.      field of TARGET.  */
  10507.       
  10508.       for (elt = CONSTRUCTOR_ELTS (constr); elt; elt = TREE_CHAIN (elt))
  10509.     {
  10510.       register tree field = TREE_PURPOSE (elt);
  10511.       register enum machine_mode mode;
  10512.       int bitsize;
  10513.       int bitpos;
  10514.       int unsignedp;
  10515.       
  10516.       bitsize = TREE_INT_CST_LOW (DECL_SIZE (field)) /* * DECL_SIZE_UNIT (field) */;
  10517.       mode = DECL_MODE (field);
  10518.       unsignedp = TREE_UNSIGNED (field);
  10519.  
  10520.       bitpos = TREE_INT_CST_LOW (DECL_FIELD_BITPOS (field));
  10521.       
  10522.       bc_store_field (elt, bitsize, bitpos, mode, TREE_VALUE (elt), TREE_TYPE (TREE_VALUE (elt)),
  10523.               /* The alignment of TARGET is
  10524.                  at least what its type requires.  */
  10525.               VOIDmode, 0,
  10526.               TYPE_ALIGN (TREE_TYPE (constr)) / BITS_PER_UNIT,
  10527.               int_size_in_bytes (TREE_TYPE (constr)));
  10528.     }
  10529.     }
  10530.   else
  10531.     
  10532.     /* Constructor type is array */
  10533.     if (TREE_CODE (TREE_TYPE (constr)) == ARRAY_TYPE)
  10534.       {
  10535.     register tree elt;
  10536.     register int i;
  10537.     tree domain = TYPE_DOMAIN (TREE_TYPE (constr));
  10538.     int minelt = TREE_INT_CST_LOW (TYPE_MIN_VALUE (domain));
  10539.     int maxelt = TREE_INT_CST_LOW (TYPE_MAX_VALUE (domain));
  10540.     tree elttype = TREE_TYPE (TREE_TYPE (constr));
  10541.     
  10542.     /* If the constructor has fewer fields than the structure,
  10543.        clear the whole structure first.  */
  10544.     
  10545.     if (list_length (CONSTRUCTOR_ELTS (constr)) < maxelt - minelt + 1)
  10546.       {
  10547.         bc_emit_instruction (duplicate);
  10548.         bc_emit_instruction (constSI, (HOST_WIDE_INT) int_size_in_bytes (TREE_TYPE (constr)));
  10549.         bc_emit_instruction (clearBLK);
  10550.       }
  10551.     
  10552.     
  10553.     /* Store each element of the constructor into the corresponding
  10554.        element of TARGET, determined by counting the elements. */
  10555.     
  10556.     for (elt = CONSTRUCTOR_ELTS (constr), i = 0;
  10557.          elt;
  10558.          elt = TREE_CHAIN (elt), i++)
  10559.       {
  10560.         register enum machine_mode mode;
  10561.         int bitsize;
  10562.         int bitpos;
  10563.         int unsignedp;
  10564.         
  10565.         mode = TYPE_MODE (elttype);
  10566.         bitsize = GET_MODE_BITSIZE (mode);
  10567.         unsignedp = TREE_UNSIGNED (elttype);
  10568.         
  10569.         bitpos = (i * TREE_INT_CST_LOW (TYPE_SIZE (elttype))
  10570.               /* * TYPE_SIZE_UNIT (elttype) */ );
  10571.         
  10572.         bc_store_field (elt, bitsize, bitpos, mode,
  10573.                 TREE_VALUE (elt), TREE_TYPE (TREE_VALUE (elt)),
  10574.                 /* The alignment of TARGET is
  10575.                    at least what its type requires.  */
  10576.                 VOIDmode, 0,
  10577.                 TYPE_ALIGN (TREE_TYPE (constr)) / BITS_PER_UNIT,
  10578.                 int_size_in_bytes (TREE_TYPE (constr)));
  10579.       }
  10580.   
  10581.       }
  10582. }
  10583.  
  10584.  
  10585. /* Store the value of EXP (an expression tree) into member FIELD of
  10586.    structure at address on stack, which has type TYPE, mode MODE and
  10587.    occupies BITSIZE bits, starting BITPOS bits from the beginning of the
  10588.    structure.
  10589.  
  10590.    ALIGN is the alignment that TARGET is known to have, measured in bytes.
  10591.    TOTAL_SIZE is its size in bytes, or -1 if variable.  */
  10592.  
  10593. void
  10594. bc_store_field (field, bitsize, bitpos, mode, exp, type,
  10595.         value_mode, unsignedp, align, total_size)
  10596.      int bitsize, bitpos;
  10597.      enum machine_mode mode;
  10598.      tree field, exp, type;
  10599.      enum machine_mode value_mode;
  10600.      int unsignedp;
  10601.      int align;
  10602.      int total_size;
  10603. {
  10604.  
  10605.   /* Expand expression and copy pointer */
  10606.   bc_expand_expr (exp);
  10607.   bc_emit_instruction (over);
  10608.  
  10609.  
  10610.   /* If the component is a bit field, we cannot use addressing to access
  10611.      it.  Use bit-field techniques to store in it.  */
  10612.  
  10613.   if (DECL_BIT_FIELD (field))
  10614.     {
  10615.       bc_store_bit_field (bitpos, bitsize, unsignedp);
  10616.       return;
  10617.     }
  10618.   else
  10619.     /* Not bit field */
  10620.     {
  10621.       HOST_WIDE_INT offset = bitpos / BITS_PER_UNIT;
  10622.  
  10623.       /* Advance pointer to the desired member */
  10624.       if (offset)
  10625.     bc_emit_instruction (addconstPSI, offset);
  10626.  
  10627.       /* Store */
  10628.       bc_store_memory (type, field);
  10629.     }
  10630. }
  10631.  
  10632.  
  10633. /* Store SI/SU in bitfield */
  10634. void
  10635. bc_store_bit_field (offset, size, unsignedp)
  10636.      int offset, size, unsignedp;
  10637. {
  10638.   /* Push bitfield offset and size */
  10639.   bc_push_offset_and_size (offset, size);
  10640.  
  10641.   /* Store */
  10642.   bc_emit_instruction (sstoreBI);
  10643. }
  10644.  
  10645.  
  10646. /* Load SI/SU from bitfield */
  10647. void
  10648. bc_load_bit_field (offset, size, unsignedp)
  10649.      int offset, size, unsignedp;
  10650. {
  10651.   /* Push bitfield offset and size */
  10652.   bc_push_offset_and_size (offset, size);
  10653.  
  10654.   /* Load: sign-extend if signed, else zero-extend */
  10655.   bc_emit_instruction (unsignedp ? zxloadBI : sxloadBI);
  10656. }  
  10657.  
  10658.  
  10659. /* Adjust interpreter stack by NLEVELS.  Positive means drop NLEVELS
  10660.    (adjust stack pointer upwards), negative means add that number of
  10661.    levels (adjust the stack pointer downwards).  Only positive values
  10662.    normally make sense. */
  10663.  
  10664. void
  10665. bc_adjust_stack (nlevels)
  10666.      int nlevels;
  10667. {
  10668.   switch (nlevels)
  10669.     {
  10670.     case 0:
  10671.       break;
  10672.       
  10673.     case 2:
  10674.       bc_emit_instruction (drop);
  10675.       
  10676.     case 1:
  10677.       bc_emit_instruction (drop);
  10678.       break;
  10679.       
  10680.     default:
  10681.       
  10682.       bc_emit_instruction (adjstackSI, (HOST_WIDE_INT) nlevels);
  10683.       stack_depth -= nlevels;
  10684.     }
  10685.  
  10686. #if defined (VALIDATE_STACK_FOR_BC)
  10687.   VALIDATE_STACK_FOR_BC ();
  10688. #endif
  10689. }
  10690.